33 breaking releases

0.45.0 May 13, 2024
0.43.0 Apr 2, 2024
0.42.0 Mar 18, 2024
0.35.2 Dec 21, 2023
0.13.0 Mar 27, 2023

#846 in HTTP server

Download history 3/week @ 2024-01-29 140/week @ 2024-02-12 12/week @ 2024-02-19 27/week @ 2024-02-26 279/week @ 2024-03-04 710/week @ 2024-03-11 124/week @ 2024-03-18 160/week @ 2024-04-01 5/week @ 2024-04-08 127/week @ 2024-04-22 137/week @ 2024-05-13

264 downloads per month

Apache-2.0

32KB
507 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

~15–27MB
~410K SLoC