36 breaking releases

0.48.0 Oct 1, 2024
0.47.0 Jul 23, 2024
0.46.0 Jun 13, 2024
0.42.0 Mar 18, 2024
0.13.0 Mar 27, 2023

#1052 in HTTP server

Download history 122/week @ 2024-07-22 4/week @ 2024-07-29 22/week @ 2024-09-16 5/week @ 2024-09-23 168/week @ 2024-09-30 19/week @ 2024-10-07

214 downloads per month

Apache-2.0

38KB
684 lines

Shuttle service integration for the Thruster web framework

Example

use thruster::{
    context::basic_hyper_context::{generate_context, BasicHyperContext as Ctx, HyperRequest},
    m, middleware_fn, App, HyperServer, MiddlewareNext, MiddlewareResult, ThrusterServer,
};

#[middleware_fn]
async fn hello(mut context: Ctx, _next: MiddlewareNext<Ctx>) -> MiddlewareResult<Ctx> {
    context.body("Hello, World!");
    Ok(context)
}

#[shuttle_runtime::main]
async fn thruster() -> shuttle_thruster::ShuttleThruster<HyperServer<Ctx, ()>> {
    let server = HyperServer::new(
        App::<HyperRequest, Ctx, ()>::create(generate_context, ()).get("/", m![hello]),
    );

    Ok(server.into())
}

Dependencies

~19–32MB
~503K SLoC