Crates.io | obsidian |
lib.rs | obsidian |
version | 0.2.2 |
source | src |
created_at | 2018-10-04 17:11:40.650589 |
updated_at | 2020-05-03 08:27:38.096381 |
description | Ergonomic async http framework for amazing, reliable and efficient web |
homepage | https://obsidian-rs.github.io |
repository | https://github.com/obsidian-rs/obsidian |
max_upload_size | |
id | 88050 |
size | 166,289 |
Obsidian is an ergonomic Rust async http framework for reliable and efficient web.
use obsidian::{context::Context, App};
#[tokio::main]
async fn main() {
let mut app: App = App::new();
let addr = ([127, 0, 0, 1], 3000).into();
app.get("/", |ctx: Context| async { ctx.build("Hello World").ok() });
app.listen(&addr, || {
println!("server is listening to {}", &addr);
}).await;
}
use obsidian::{context::Context, App, ContextResult};
async fn hello_world(ctx: Context) -> ContextResult {
ctx.build("Hello World").ok()
}
#[tokio::main]
async fn main() {
let mut app: App = App::new();
let addr = ([127, 0, 0, 1], 3000).into();
app.get("/", hello_world);
app.listen(&addr, || {
println!("server is listening to {}", &addr);
})
.await;
}
use obsidian::{context::Context, App, ContextResult};
use serde::*;
async fn get_user(ctx: Context) -> ContextResult {
#[derive(Serialize, Deserialize)]
struct User {
name: String,
};
let user = User {
name: String::from("Obsidian"),
};
ctx.build_json(user).ok()
}
#[tokio::main]
async fn main() {
let mut app: App = App::new();
let addr = ([127, 0, 0, 1], 3000).into();
app.get("/user", get_user);
app.listen(&addr, || {
println!("server is listening to {}", &addr);
})
.await;
}
Example are located in example/main.rs
.
cargo run --example example
NOT READY FOR PRODUCTION YET!