Shuttle Documentation

repository·main·Indexed 27 days ago

https://github.com/shuttle-hq/shuttle

A platform for building and shipping Rust applications with one-line resource provisioning. Shuttle handles infrastructure, security, and deployment via a specialized CLI and runtime. It supports web frameworks like Axum, Actix Web, and Poem, and provides plugins for provisioning Postgres, AWS RDS, Turso, and OpenDAL storage.

Tokens
23.7K
Snippets
59
Records
190
Agent score
92%

What's inside Shuttle

  1. Integrate Poem with Shuttle

    main

    To use the Poem web framework with Shuttle, use the ShuttlePoem type in your main function. Your main function should be annotated with #[shuttle_runtime::main] and return a ShuttlePoem<impl poem::Endpoint>. You can convert a Poem Route into a ShuttlePoem using the .into() method.

    use poem::{get, handler, Route};
    use shuttle_poem::ShuttlePoem;
    
    #[handler]
    fn hello_world() -> &'static str {
        "Hello, world!"
    }
    
    #[shuttle_runtime::main]
    async fn poem() -> ShuttlePoem<impl poem::Endpoint> {
        let app = Route::new().at("/", get(hello_world));
    
        Ok(app.into())
    }
  2. Use Axum 0.7 with shuttle-axum

    main

    If your project requires Axum 0.7 instead of the default Axum 0.8, you must disable default features for shuttle-axum and explicitly enable the axum-0-7 feature flag in your Cargo.toml.

    axum = "0.7.3"
    shuttle-axum = { version = "...", default-features = false, features = ["axum-0-7"] }
  3. Implement custom resource plugins using ResourceInputBuilder

    main

    To extend Shuttle with custom managed resources, you must implement the ResourceInputBuilder trait. You can find implementation patterns by examining existing plugins in the repository or by reviewing the official custom resource examples in the shuttle-examples repository.

    https://github.com/shuttle-hq/shuttle-examples/tree/main/custom-resource
  4. Integrate Shuttle with the Salvo web framework

    main

    To use Salvo with Shuttle, define your main function using the #[shuttle_runtime::main] attribute and return a shuttle_salvo::ShuttleSalvo type. You can convert a Salvo Router into this type using the .into() method.

    use salvo::prelude::*;
    
    #[handler]
    async fn hello_world(res: &mut Response) {
        res.render(Text::Plain("Hello, world!"));
    }
    
    #[shuttle_runtime::main]
    async fn salvo() -> shuttle_salvo::ShuttleSalvo {
        let router = Router::new().get(hello_world);
    
        Ok(router.into())
    }
  5. Install the Shuttle CLI

    main

    Install the Shuttle CLI to deploy Rust applications using a single command. Use the appropriate command for your operating system.

    # Linux / macOS
    curl -sSfL https://www.shuttle.dev/install | bash
    
    # Windows (Powershell)
    iwr https://www.shuttle.dev/install-win | iex
  6. Integrate Shuttle with the Rocket web framework

    main

    To deploy a Rocket application on Shuttle, use the shuttle_rocket::ShuttleRocket type as the return type for your #[shuttle_runtime::main] entry point. You can convert a standard Rocket instance into a Shuttle-compatible service using the .into() method.

    use rocket::{get, routes};
    
    #[get("/")]
    fn index() -> &'static str {
        "Hello, world!"
    }
    
    #[shuttle_runtime::main]
    async fn rocket() -> shuttle_rocket::ShuttleRocket {
        let rocket = rocket::build().mount("/", routes![index]);
    
        Ok(rocket.into())
    }