Skip to content

yonasBSD/web-server.rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

web-server.rs

Licenses Linting Testing Packaging Cross-Build

Security Audit Scorecard Audit Quality Gate Status Security Rating Vulnerabilities

GitHub last commit Dependency Status Rust GitHub Release License

High performance, general purpose web server.

Features

  • based on high performance Axum web framework
  • uses Tower middleware
  • Tako web framework optimizations
  • built-in OpenAPI support (Swagger UI and Scalar)

Example

use anyhow::Result;
use web_server_rs::{*, prelude::*};

async fn hello() -> Response {
    http::Response::builder()
        .status(http::StatusCode::OK)
        .body(Body::from("Hello World"))
        .unwrap()
}

async fn health() -> impl Responder {
    Json!({ "status": "healthy" })
}

#[tokio::main]
async fn main() -> Result<()> {
    let config: ServerConfig = ServerConfig {
        routes: vec![
            Route {
                method: Method::GET,
                path: "/",
                handler: handler!(hello),
                operation_id: "hello",
                summary: "Hello endpoint",
                description: None,
                tag: "example",
                response_code: 200,
                response_desc: "OK",
            },
            Route {
                method: Method::GET,
                path: "/health",
                handler: handler!(health),
                operation_id: "health",
                summary: "health endpoint",
                description: None,
                tag: "example",
                response_code: 200,
                response_desc: "OK",
            },
        ],
        address: "0.0.0.0",
        port: 3000,
        ..Default::default()
    };

    serve(config).await
}

About

High performance Axum-based web server with Tower middleware, Tako optimizations, and automatic OpenAPI generation (Swagger UI and Scalar)

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors