Coder Social home page Coder Social logo

nova's Introduction

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.

nova's People

Contributors

pw-order-of-devs avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.