-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add hosting instructions/example for Shuttle
- Loading branch information
Showing
5 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "example-shuttle" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[dependencies] | ||
axum = "0.6.20" | ||
tokio = { version = "1.0", features = ["full"] } | ||
shuttle-axum = "0.31" | ||
shuttle-runtime = "0.31" | ||
tracing = "0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Hosting on Shuttle | ||
|
||
<img width="300" src="https://raw.githubusercontent.com/shuttle-hq/shuttle/master/assets/logo-rectangle-transparent.png"/> | ||
|
||
> [**Shuttle**](https://www.shuttle.rs) is a Rust-native cloud development platform that lets you deploy your Rust apps for free. | ||
Shuttle has out-of-the-box support for Axum. You can follow these steps to run the example: | ||
|
||
1. Install `cargo-shuttle`: | ||
|
||
```sh | ||
cargo install cargo-shuttle | ||
``` | ||
|
||
2. Run the example locally: | ||
|
||
```sh | ||
cargo shuttle run --working-directory examples/hosting-on-shuttle | ||
``` | ||
|
||
If you want to create a project and deploy a service: | ||
|
||
1. Log in into Shuttle console: | ||
|
||
```sh | ||
cargo shuttle login | ||
``` | ||
|
||
2. Create a project: | ||
|
||
```sh | ||
cargo shuttle project start | ||
``` | ||
|
||
3. Deploy! 🚀 | ||
|
||
```sh | ||
cargo shuttle deploy | ||
``` | ||
|
||
Check out the complete Axum examples [here](https://github.com/shuttle-hq/shuttle-examples/tree/main/axum). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//! Run with | ||
//! | ||
//! ```not_rust | ||
//! cargo shuttle run --working-directory examples/hosting-on-shuttle | ||
//! ``` | ||
use axum::{routing::get, Router}; | ||
|
||
#[shuttle_runtime::main] | ||
async fn main() -> shuttle_axum::ShuttleAxum { | ||
// build our application with a route | ||
let router = Router::new().route("/", get(hello_world)); | ||
|
||
// start the server | ||
tracing::info!("starting the server"); | ||
Ok(router.into()) | ||
} | ||
|
||
async fn hello_world() -> &'static str { | ||
"Hello, world!" | ||
} |