nova_core

Crates.ionova_core
lib.rsnova_core
version0.0.1
sourcesrc
created_at2023-10-11 10:12:42.139239
updated_at2023-10-11 10:12:42.139239
descriptionnova - core structures, types and traits
homepagehttps://github.com/pw-order-of-devs
repositoryhttps://github.com/pw-order-of-devs/nova
max_upload_size
id1000043
size38,972
Paweł Walus (pw-order-of-devs)

documentation

README

nova

nova_web - a web server framework written in Rust

crates.io Documentation MIT or Apache 2.0 licensed MSRV
CI downloads Dependency Status

More information about this crate can be found in the crate documentation.
Examples of how to use the crate can be found in examples.

Crate features

  • Macro-free routing handling
  • serde integration for parsing request body
  • [todo] Handlers registered by macros
  • [todo] OpenApi support
  • custom Middleware integration
  • [todo] custom Dependency Injection integration

[todo] Custom middleware include pre-implemented commonly used middlewares like [middleware..].
Custom Dependency Injection provides a flexibility to control the dependencies like database connection or other external integrations.

Usage example

in Cargo.toml:

[dependencies]
nova_web = "0.0.1"
tokio = "1.32"
serde = { version = "1.0", features = ["derive"] }
use nova_web::prelude::*;

#[derive(Debug, Deserialize, Serialize)]
struct RequestBody {
    id: String,
    name: String,
}

fn hello_world(_: &HttpRequest, res: &mut HttpResponse) -> ServerResponse {
    Ok(res
        .status(HttpStatus::OK)
        .body("Hello, world!".as_bytes()))
}

fn hello_json(req: &HttpRequest, res: &mut HttpResponse) -> ServerResponse {
    let body: RequestBody = req.json()?;
    Ok(res
        .status(HttpStatus::OK)
        .body(format!("Hello, {}!", body.name).as_bytes()))
}

#[tokio::main]
async fn main() -> Result<(), ServerError> {
    Server::create("0.0.0.0", 3000)
        .service("/hello", vec![
            get("/", hello_world),
            post("/json", hello_json),
        ].into())
        .bind()
        .await
}

Performance

[todo] prepare benchmarks

Safety

This crate uses restrictive linter settings on top of #![forbid(unsafe_code)] to ensure safety and clearness of source code.

Minimum supported Rust version

MSRV for nova is 1.63

Examples

Usage examples can be found here. The docs also include code snippets.
[todo] More examples, snippets and information can be found on wiki.

License

The project is licensed under the Apache license or MIT license

Contribution

Unless explicitly stated otherwise, any contribution intentionally submitted for inclusion in nova, shall be licensed as Apache or MIT, without any additional terms or conditions.

Commit count: 2

cargo fmt