Crates.io | nova_core |
lib.rs | nova_core |
version | 0.0.1 |
source | src |
created_at | 2023-10-11 10:12:42.139239 |
updated_at | 2023-10-11 10:12:42.139239 |
description | nova - core structures, types and traits |
homepage | https://github.com/pw-order-of-devs |
repository | https://github.com/pw-order-of-devs/nova |
max_upload_size | |
id | 1000043 |
size | 38,972 |
nova_web
- a web server framework written in Rust
More information about this crate can be found in the crate documentation.
Examples of how to use the crate can be found in examples.
[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.
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
}
[todo] prepare benchmarks
This crate uses restrictive linter settings on top of #![forbid(unsafe_code)]
to ensure safety and clearness of source code.
MSRV
for nova
is 1.63
Usage examples can be found here. The docs also include code snippets.
[todo] More examples, snippets and information can be found on wiki.
The project is licensed under the Apache license or MIT license
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.