shuttle-thruster

Crates.ioshuttle-thruster
lib.rsshuttle-thruster
version0.46.0
sourcesrc
created_at2023-03-14 12:32:21.343913
updated_at2024-06-13 10:10:13.285582
descriptionService implementation to run a thruster webserver on shuttle
homepage
repositoryhttps://github.com/shuttle-hq/shuttle
max_upload_size
id809816
size3,246
(jonaro00)

documentation

README

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())
}
Commit count: 1307

cargo fmt