mirror of
https://github.com/actix/actix-website
synced 2025-06-27 15:39:02 +02:00
Add hosting instructions for Shuttle (#334)
* Add hosting instructions for Shuttle * move shuttle sample code to examples dir --------- Co-authored-by: Rob Ede <robjtede@icloud.com>
This commit is contained in:
@ -19,6 +19,7 @@ members = [
|
||||
"responder-trait",
|
||||
"responses",
|
||||
"server",
|
||||
"shuttle",
|
||||
"static-files",
|
||||
"testing",
|
||||
"url-dispatch",
|
||||
|
12
examples/shuttle/Cargo.toml
Normal file
12
examples/shuttle/Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "shuttle"
|
||||
version = "1.0.0"
|
||||
edition = "2021"
|
||||
|
||||
# <shuttle-deps>
|
||||
[dependencies]
|
||||
actix-web = "4"
|
||||
shuttle-actix-web = "0.30"
|
||||
shuttle-runtime = "0.30"
|
||||
tokio = "1"
|
||||
# </shuttle-deps>
|
19
examples/shuttle/src/main.rs
Normal file
19
examples/shuttle/src/main.rs
Normal file
@ -0,0 +1,19 @@
|
||||
#[get("/")]
|
||||
async fn hello_world() -> impl actix_web::Responder {
|
||||
"hello world"
|
||||
}
|
||||
|
||||
// <shuttle-hello-world>
|
||||
use actix_web::{get, web::ServiceConfig};
|
||||
use shuttle_actix_web::ShuttleActixWeb;
|
||||
|
||||
#[shuttle_runtime::main]
|
||||
async fn main() -> ShuttleActixWeb<impl FnOnce(&mut ServiceConfig) + Send + Clone + 'static> {
|
||||
let config = move |cfg: &mut ServiceConfig| {
|
||||
// set up your service here, e.g.:
|
||||
cfg.service(hello_world);
|
||||
};
|
||||
|
||||
Ok(config.into())
|
||||
}
|
||||
// </shuttle-hello-world>
|
Reference in New Issue
Block a user