https://github.com/obsidian-rs/obsidian
Ergonomic async http framework for reliable and efficient web
https://github.com/obsidian-rs/obsidian
async await framework http-framework rust web-development
Last synced: about 1 month ago
JSON representation
Ergonomic async http framework for reliable and efficient web
- Host: GitHub
- URL: https://github.com/obsidian-rs/obsidian
- Owner: obsidian-rs
- License: mit
- Archived: true
- Created: 2018-09-30T16:37:53.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-06-20T10:42:43.000Z (over 4 years ago)
- Last Synced: 2024-11-16T18:13:42.411Z (12 months ago)
- Topics: async, await, framework, http-framework, rust, web-development
- Language: Rust
- Homepage:
- Size: 1.51 MB
- Stars: 27
- Watchers: 8
- Forks: 4
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
Obsidian
Obsidian is an ergonomic Rust async http framework for reliable and efficient web.
## Get Started
```toml
[dependencies]
# add these 2 dependencies in Cargo.toml file
obsidian = "0.2.2"
tokio = "0.2.21"
```
## Hello World
```rust
use obsidian::{context::Context, App};
#[tokio::main]
async fn main() {
let mut app: App = App::new();
app.get("/", |ctx: Context| async { ctx.build("Hello World").ok() });
app.listen(3000).await;
}
```
## Hello World (with handler function)
```rust
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();
app.get("/", hello_world);
app.listen(3000).await;
}
```
## JSON Response
```rust
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();
app.get("/user", get_user);
app.listen(3000).await;
}
```
## Example Files
Example are located in `example/main.rs`.
## Run Example
```
cargo run --example example
```
## Current State
NOT READY FOR PRODUCTION YET!