-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
32 additions
and
188 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
target | ||
Dockerfile | ||
README.md | ||
Tiltfile |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,16 +1,21 @@ | ||
use axum::Extension; | ||
use axum_aws_lambda::LambdaLayer; | ||
use std::{env, net::SocketAddr}; | ||
|
||
use axum::{Extension, Server}; | ||
use redis::aio::ConnectionManager; | ||
use tower::ServiceBuilder; | ||
|
||
use crate::routes; | ||
|
||
pub async fn start(redis: ConnectionManager) { | ||
let router = routes::handler().layer(Extension(redis)); | ||
let app = routes::handler().layer(Extension(redis)); | ||
|
||
let app = ServiceBuilder::new() | ||
.layer(LambdaLayer::default()) | ||
.service(router); | ||
let address = SocketAddr::from(( | ||
[0, 0, 0, 0], | ||
env::var("PORT").map_or(8000, |p| p.parse().unwrap()), | ||
)); | ||
|
||
lambda_http::run(app).await.unwrap(); | ||
println!("🪩 World Bridge started on http://{address}"); | ||
Server::bind(&address) | ||
.serve(app.into_make_service()) | ||
.await | ||
.expect("Failed to start server"); | ||
} |