Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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: 25 days ago
JSON representation

Ergonomic async http framework for reliable and efficient web

Awesome Lists containing this project

README

        



Obsidian Logo


Obsidian

Obsidian is an ergonomic Rust async http framework for reliable and efficient web.



Obsidian crate


GitHub Actions status


Obsidian serve

## 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!