-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(service): Add thruster framework as service
Adds the [thruster](https://github.com/thruster-rs/Thruster) framework as a launchable target for use with shuttle.rs. Also includes a hello-world and postgres example.
- Loading branch information
Showing
12 changed files
with
293 additions
and
13 deletions.
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
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,10 @@ | ||
[package] | ||
name = "hello-world" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
|
||
[dependencies] | ||
shuttle-service = { version = "0.5.2", features = ["web-thruster"] } | ||
thruster = { version = "1.2.6", features = ["hyper_server"] } |
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 @@ | ||
name = "hello-world-thruster-app" |
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,17 @@ | ||
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_service::main] | ||
async fn thruster() -> shuttle_service::ShuttleThruster<HyperServer<Ctx, ()>> { | ||
Ok(HyperServer::new( | ||
App::<HyperRequest, Ctx, ()>::create(generate_context, ()).get("/hello", m![hello]), | ||
)) | ||
} |
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,17 @@ | ||
[package] | ||
name = "postgres" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
hyper = "0.14.20" | ||
serde = { version = "1.0", features = ["derive"] } | ||
serde_json = { version = "1.0" } | ||
shuttle-aws-rds = { version = "0.5.2", features = ["postgres"] } | ||
shuttle-service = { version = "0.5.2", features = ["web-thruster"] } | ||
sqlx = { version = "0.6", features = ["runtime-tokio-native-tls", "postgres"] } | ||
thruster = { version = "1.2.6", features = ["hyper_server"] } |
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 @@ | ||
name = "postgres-tide-app" |
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,6 @@ | ||
DROP TABLE IF EXISTS todos; | ||
|
||
CREATE TABLE todos ( | ||
id serial PRIMARY KEY, | ||
note TEXT NOT NULL | ||
); |
Oops, something went wrong.