From 2413236898f149041e4ec22cbff3d23de313ac33 Mon Sep 17 00:00:00 2001 From: Emilia Jaser <58911293+schitcrafter@users.noreply.github.com> Date: Sat, 18 Nov 2023 02:59:33 +0100 Subject: [PATCH] In the examples, listen on 0.0.0.0 instead of 127.0.0.1 #664 (#672) * In the examples, listen on 0.0.0.0 instead of 127.0.0.1 #664 * Fix accidentally replaced ip's --- examples/grpc/helloworld/src/main.rs | 2 +- examples/grpc/jsoncodec/src/main.rs | 2 +- examples/grpc/middleware/src/main.rs | 2 +- examples/grpc/reflection/src/main.rs | 2 +- examples/grpc/routeguide/src/main.rs | 2 +- examples/openapi/auth-apikey/src/main.rs | 2 +- examples/openapi/auth-basic/src/main.rs | 2 +- examples/openapi/auth-github/src/main.rs | 2 +- examples/openapi/auth-multiple/src/main.rs | 2 +- examples/openapi/combined-apis/src/main.rs | 2 +- examples/openapi/content-type-accept/src/main.rs | 2 +- examples/openapi/custom-payload/src/main.rs | 2 +- examples/openapi/generics/src/main.rs | 2 +- examples/openapi/hello-world/src/main.rs | 2 +- examples/openapi/log-with-operation-id/src/main.rs | 2 +- examples/openapi/poem-extractor/src/main.rs | 2 +- examples/openapi/poem-middleware/src/main.rs | 2 +- examples/openapi/sse/src/main.rs | 2 +- examples/openapi/todos/src/main.rs | 2 +- examples/openapi/uniform-response/src/main.rs | 2 +- examples/openapi/union/src/main.rs | 2 +- examples/openapi/upload/src/main.rs | 2 +- examples/openapi/users-crud/src/main.rs | 2 +- examples/poem/async-graphql/src/main.rs | 2 +- examples/poem/auth/src/main.rs | 2 +- examples/poem/basic-auth/src/main.rs | 2 +- examples/poem/catch-panic/src/main.rs | 2 +- examples/poem/combined-listeners/src/main.rs | 6 +++--- examples/poem/cookie-session/src/main.rs | 2 +- examples/poem/csrf/src/main.rs | 2 +- examples/poem/custom-error/src/main.rs | 2 +- examples/poem/custom-extractor/src/main.rs | 2 +- examples/poem/embed-files/src/main.rs | 2 +- examples/poem/graceful-shutdown/src/main.rs | 2 +- examples/poem/handling-404/src/main.rs | 2 +- examples/poem/hello-world/src/main.rs | 2 +- examples/poem/i18n/src/main.rs | 2 +- examples/poem/json/src/main.rs | 2 +- examples/poem/middleware/src/main.rs | 2 +- examples/poem/middleware_fn/src/main.rs | 2 +- examples/poem/mongodb/src/main.rs | 2 +- examples/poem/nested-routing/src/main.rs | 2 +- examples/poem/opentelemetry-jaeger/src/server1.rs | 2 +- examples/poem/opentelemetry-jaeger/src/server2.rs | 2 +- examples/poem/redis-session/src/main.rs | 2 +- examples/poem/sse/src/main.rs | 2 +- examples/poem/static-files/src/main.rs | 2 +- examples/poem/tera-templating/src/main.rs | 2 +- examples/poem/tls-reload/src/main.rs | 2 +- examples/poem/tls/src/main.rs | 2 +- examples/poem/tokio-metrics/src/main.rs | 2 +- examples/poem/tonic/src/main.rs | 2 +- examples/poem/tower-layer/src/main.rs | 2 +- examples/poem/upload/src/main.rs | 2 +- examples/poem/websocket-chat/src/main.rs | 2 +- poem-grpc/README.md | 2 +- poem-openapi/README.md | 2 +- poem-openapi/src/lib.rs | 2 +- poem/README.md | 2 +- poem/src/lib.rs | 2 +- poem/src/listener/mod.rs | 2 +- poem/src/listener/rustls.rs | 2 +- 62 files changed, 64 insertions(+), 64 deletions(-) diff --git a/examples/grpc/helloworld/src/main.rs b/examples/grpc/helloworld/src/main.rs index c127c6746d..f147740868 100644 --- a/examples/grpc/helloworld/src/main.rs +++ b/examples/grpc/helloworld/src/main.rs @@ -21,7 +21,7 @@ impl Greeter for GreeterService { #[tokio::main] async fn main() -> Result<(), std::io::Error> { let route = RouteGrpc::new().add_service(GreeterServer::new(GreeterService)); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(route) .await } diff --git a/examples/grpc/jsoncodec/src/main.rs b/examples/grpc/jsoncodec/src/main.rs index 017fac56a9..d1359216a0 100644 --- a/examples/grpc/jsoncodec/src/main.rs +++ b/examples/grpc/jsoncodec/src/main.rs @@ -25,7 +25,7 @@ async fn main() -> Result<(), std::io::Error> { } tracing_subscriber::fmt::init(); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run( RouteGrpc::new() .add_service(GreeterServer::new(GreeterService)) diff --git a/examples/grpc/middleware/src/main.rs b/examples/grpc/middleware/src/main.rs index fceb973c6f..ad437bfa9b 100644 --- a/examples/grpc/middleware/src/main.rs +++ b/examples/grpc/middleware/src/main.rs @@ -22,7 +22,7 @@ impl Greeter for GreeterService { #[tokio::main] async fn main() -> Result<(), std::io::Error> { - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(RouteGrpc::new().add_service(GreeterServer::new(GreeterService))) .await } diff --git a/examples/grpc/reflection/src/main.rs b/examples/grpc/reflection/src/main.rs index 83f801c15e..504d3fb033 100644 --- a/examples/grpc/reflection/src/main.rs +++ b/examples/grpc/reflection/src/main.rs @@ -26,7 +26,7 @@ async fn main() -> Result<(), std::io::Error> { } tracing_subscriber::fmt::init(); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run( RouteGrpc::new() .add_service( diff --git a/examples/grpc/routeguide/src/main.rs b/examples/grpc/routeguide/src/main.rs index cc49e5ff31..b6a3494079 100644 --- a/examples/grpc/routeguide/src/main.rs +++ b/examples/grpc/routeguide/src/main.rs @@ -148,7 +148,7 @@ async fn main() -> Result<(), std::io::Error> { } tracing_subscriber::fmt::init(); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run( RouteGrpc::new() .add_service(RouteGuideServer::new(RouteGuideService { diff --git a/examples/openapi/auth-apikey/src/main.rs b/examples/openapi/auth-apikey/src/main.rs index 1909ff15ba..590ed327dc 100644 --- a/examples/openapi/auth-apikey/src/main.rs +++ b/examples/openapi/auth-apikey/src/main.rs @@ -84,7 +84,7 @@ async fn main() -> Result<(), std::io::Error> { .nest("/", ui) .data(server_key); - poem::Server::new(TcpListener::bind("127.0.0.1:3000")) + poem::Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/openapi/auth-basic/src/main.rs b/examples/openapi/auth-basic/src/main.rs index 6d8ec12956..1c5a7b37a1 100644 --- a/examples/openapi/auth-basic/src/main.rs +++ b/examples/openapi/auth-basic/src/main.rs @@ -33,7 +33,7 @@ async fn main() -> Result<(), std::io::Error> { OpenApiService::new(Api, "Authorization Demo", "1.0").server("http://localhost:3000/api"); let ui = api_service.swagger_ui(); - poem::Server::new(TcpListener::bind("127.0.0.1:3000")) + poem::Server::new(TcpListener::bind("0.0.0.0:3000")) .run(Route::new().nest("/api", api_service).nest("/", ui)) .await } diff --git a/examples/openapi/auth-github/src/main.rs b/examples/openapi/auth-github/src/main.rs index 531e5f2fa4..797c377a46 100644 --- a/examples/openapi/auth-github/src/main.rs +++ b/examples/openapi/auth-github/src/main.rs @@ -91,7 +91,7 @@ async fn main() -> Result<(), std::io::Error> { OpenApiService::new(Api, "Authorization Demo", "1.0").server("http://localhost:3000/api"); let ui = api_service.swagger_ui(); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run( Route::new() .at("/proxy", oauth_token_url_proxy) diff --git a/examples/openapi/auth-multiple/src/main.rs b/examples/openapi/auth-multiple/src/main.rs index 9512a2ee1a..04b057c376 100644 --- a/examples/openapi/auth-multiple/src/main.rs +++ b/examples/openapi/auth-multiple/src/main.rs @@ -99,7 +99,7 @@ async fn main() -> Result<(), std::io::Error> { .nest("/", ui) .data(server_key); - poem::Server::new(TcpListener::bind("127.0.0.1:3000")) + poem::Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/openapi/combined-apis/src/main.rs b/examples/openapi/combined-apis/src/main.rs index e81900d807..3eaa7dfcea 100644 --- a/examples/openapi/combined-apis/src/main.rs +++ b/examples/openapi/combined-apis/src/main.rs @@ -42,7 +42,7 @@ async fn main() -> Result<(), std::io::Error> { .server("http://localhost:3000/api"); let ui = api_service.swagger_ui(); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(Route::new().nest("/api", api_service).nest("/", ui)) .await } diff --git a/examples/openapi/content-type-accept/src/main.rs b/examples/openapi/content-type-accept/src/main.rs index b077d78bed..564995136c 100644 --- a/examples/openapi/content-type-accept/src/main.rs +++ b/examples/openapi/content-type-accept/src/main.rs @@ -142,7 +142,7 @@ async fn main() -> Result<(), std::io::Error> { let ui = api_service.swagger_ui(); let yaml = api_service.spec_endpoint(); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run( Route::new() .nest("/api", api_service) diff --git a/examples/openapi/custom-payload/src/main.rs b/examples/openapi/custom-payload/src/main.rs index bfcc0a826e..487d0a589c 100644 --- a/examples/openapi/custom-payload/src/main.rs +++ b/examples/openapi/custom-payload/src/main.rs @@ -32,7 +32,7 @@ async fn main() -> Result<(), std::io::Error> { OpenApiService::new(Api, "Hello World", "1.0").server("http://localhost:3000/api"); let ui = api_service.swagger_ui(); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(Route::new().nest("/api", api_service).nest("/", ui)) .await } diff --git a/examples/openapi/generics/src/main.rs b/examples/openapi/generics/src/main.rs index 9be68c62cc..3e36140670 100644 --- a/examples/openapi/generics/src/main.rs +++ b/examples/openapi/generics/src/main.rs @@ -36,7 +36,7 @@ async fn main() -> Result<(), std::io::Error> { OpenApiService::new(Api, "Hello World", "1.0").server("http://localhost:3000/api"); let ui = api_service.swagger_ui(); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(Route::new().nest("/api", api_service).nest("/", ui)) .await } diff --git a/examples/openapi/hello-world/src/main.rs b/examples/openapi/hello-world/src/main.rs index deb1fdc8b0..ea2525c2f3 100644 --- a/examples/openapi/hello-world/src/main.rs +++ b/examples/openapi/hello-world/src/main.rs @@ -25,7 +25,7 @@ async fn main() -> Result<(), std::io::Error> { OpenApiService::new(Api, "Hello World", "1.0").server("http://localhost:3000/api"); let ui = api_service.swagger_ui(); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(Route::new().nest("/api", api_service).nest("/", ui)) .await } diff --git a/examples/openapi/log-with-operation-id/src/main.rs b/examples/openapi/log-with-operation-id/src/main.rs index a6c6894809..77c5394c7b 100644 --- a/examples/openapi/log-with-operation-id/src/main.rs +++ b/examples/openapi/log-with-operation-id/src/main.rs @@ -35,7 +35,7 @@ async fn main() -> Result<(), std::io::Error> { Ok(resp) }); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/openapi/poem-extractor/src/main.rs b/examples/openapi/poem-extractor/src/main.rs index 9d4a757229..af6ddf92c9 100644 --- a/examples/openapi/poem-extractor/src/main.rs +++ b/examples/openapi/poem-extractor/src/main.rs @@ -22,7 +22,7 @@ async fn main() -> Result<(), std::io::Error> { OpenApiService::new(Api, "Poem Extractor", "1.0").server("http://localhost:3000/api"); let ui = api_service.swagger_ui(); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run( Route::new() .nest("/api", api_service.data(100i32)) diff --git a/examples/openapi/poem-middleware/src/main.rs b/examples/openapi/poem-middleware/src/main.rs index b97ad6a61c..8f26200f20 100644 --- a/examples/openapi/poem-middleware/src/main.rs +++ b/examples/openapi/poem-middleware/src/main.rs @@ -26,7 +26,7 @@ async fn main() -> Result<(), std::io::Error> { OpenApiService::new(Api, "Poem Middleware", "1.0").server("http://localhost:3000/api"); let ui = api_service.swagger_ui(); - poem::Server::new(TcpListener::bind("127.0.0.1:3000")) + poem::Server::new(TcpListener::bind("0.0.0.0:3000")) .run(Route::new().nest("/api", api_service).nest("/", ui)) .await } diff --git a/examples/openapi/sse/src/main.rs b/examples/openapi/sse/src/main.rs index 51444b0b4c..6690093d11 100644 --- a/examples/openapi/sse/src/main.rs +++ b/examples/openapi/sse/src/main.rs @@ -37,7 +37,7 @@ async fn main() -> Result<(), std::io::Error> { OpenApiService::new(Api, "Hello World", "1.0").server("http://localhost:3000/api"); let ui = api_service.swagger_ui(); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(Route::new().nest("/api", api_service).nest("/", ui)) .await } diff --git a/examples/openapi/todos/src/main.rs b/examples/openapi/todos/src/main.rs index 4158f885fe..00026c06ea 100644 --- a/examples/openapi/todos/src/main.rs +++ b/examples/openapi/todos/src/main.rs @@ -158,7 +158,7 @@ async fn main() -> Result<(), Box> { .with(Cors::new()) .data(pool); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(route) .await?; Ok(()) diff --git a/examples/openapi/uniform-response/src/main.rs b/examples/openapi/uniform-response/src/main.rs index bcea502232..6c723eb200 100644 --- a/examples/openapi/uniform-response/src/main.rs +++ b/examples/openapi/uniform-response/src/main.rs @@ -104,7 +104,7 @@ async fn main() -> Result<(), std::io::Error> { .server("http://localhost:3000/api"); let ui = api_service.swagger_ui(); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(Route::new().nest("/api", api_service).nest("/", ui)) .await } diff --git a/examples/openapi/union/src/main.rs b/examples/openapi/union/src/main.rs index f151c6f38c..d21ae13ca4 100644 --- a/examples/openapi/union/src/main.rs +++ b/examples/openapi/union/src/main.rs @@ -41,7 +41,7 @@ async fn main() -> Result<(), std::io::Error> { let spec = api_service.spec_endpoint(); let spec_yaml = api_service.spec_endpoint_yaml(); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run( Route::new() .nest("/api", api_service) diff --git a/examples/openapi/upload/src/main.rs b/examples/openapi/upload/src/main.rs index 21f1fd88aa..606be9a439 100644 --- a/examples/openapi/upload/src/main.rs +++ b/examples/openapi/upload/src/main.rs @@ -101,7 +101,7 @@ async fn main() -> Result<(), std::io::Error> { .server("http://localhost:3000/api"); let ui = api_service.swagger_ui(); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(Route::new().nest("/api", api_service).nest("/", ui)) .await } diff --git a/examples/openapi/users-crud/src/main.rs b/examples/openapi/users-crud/src/main.rs index 45ddd8a4e3..84503d4a88 100644 --- a/examples/openapi/users-crud/src/main.rs +++ b/examples/openapi/users-crud/src/main.rs @@ -143,7 +143,7 @@ async fn main() -> Result<(), std::io::Error> { OpenApiService::new(Api::default(), "Users", "1.0").server("http://localhost:3000/api"); let ui = api_service.swagger_ui(); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(Route::new().nest("/api", api_service).nest("/", ui)) .await } diff --git a/examples/poem/async-graphql/src/main.rs b/examples/poem/async-graphql/src/main.rs index b3b4f9ed4a..3548800313 100644 --- a/examples/poem/async-graphql/src/main.rs +++ b/examples/poem/async-graphql/src/main.rs @@ -39,7 +39,7 @@ async fn main() -> Result<(), std::io::Error> { println!("Playground: http://localhost:3000"); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/poem/auth/src/main.rs b/examples/poem/auth/src/main.rs index b7a9cc2bf2..3cf09af856 100644 --- a/examples/poem/auth/src/main.rs +++ b/examples/poem/auth/src/main.rs @@ -105,7 +105,7 @@ async fn main() -> Result<(), std::io::Error> { .at("/signin", get(signin_ui).post(signin)) .at("/logout", get(logout)) .with(CookieSession::new(CookieConfig::new())); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/poem/basic-auth/src/main.rs b/examples/poem/basic-auth/src/main.rs index cf59468132..1d7a7ed5b4 100644 --- a/examples/poem/basic-auth/src/main.rs +++ b/examples/poem/basic-auth/src/main.rs @@ -62,7 +62,7 @@ async fn main() -> Result<(), std::io::Error> { username: "test".to_string(), password: "123456".to_string(), }); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/poem/catch-panic/src/main.rs b/examples/poem/catch-panic/src/main.rs index 9ff252f414..3d8c087768 100644 --- a/examples/poem/catch-panic/src/main.rs +++ b/examples/poem/catch-panic/src/main.rs @@ -21,7 +21,7 @@ async fn main() -> Result<(), std::io::Error> { .at("/", index) .with(Tracing) .with(CatchPanic::new()); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .name("hello-world") .run(app) .await diff --git a/examples/poem/combined-listeners/src/main.rs b/examples/poem/combined-listeners/src/main.rs index 519fd959ce..883563748e 100644 --- a/examples/poem/combined-listeners/src/main.rs +++ b/examples/poem/combined-listeners/src/main.rs @@ -17,8 +17,8 @@ async fn main() -> Result<(), std::io::Error> { tracing_subscriber::fmt::init(); let app = Route::new().at("/", get(hello)); - let listener = TcpListener::bind("127.0.0.1:3000") - .combine(TcpListener::bind("127.0.0.1:3001")) - .combine(TcpListener::bind("127.0.0.1:3002")); + let listener = TcpListener::bind("0.0.0.0:3000") + .combine(TcpListener::bind("0.0.0.0:3001")) + .combine(TcpListener::bind("0.0.0.0:3002")); Server::new(listener).run(app).await } diff --git a/examples/poem/cookie-session/src/main.rs b/examples/poem/cookie-session/src/main.rs index 31f248a82c..d13ec86456 100644 --- a/examples/poem/cookie-session/src/main.rs +++ b/examples/poem/cookie-session/src/main.rs @@ -22,7 +22,7 @@ async fn main() -> Result<(), std::io::Error> { let app = Route::new() .at("/", get(count)) .with(CookieSession::new(CookieConfig::default().secure(false))); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/poem/csrf/src/main.rs b/examples/poem/csrf/src/main.rs index 342d09f547..450122acb5 100644 --- a/examples/poem/csrf/src/main.rs +++ b/examples/poem/csrf/src/main.rs @@ -60,7 +60,7 @@ async fn main() -> Result<(), std::io::Error> { let app = Route::new() .at("/", get(login_ui).post(login)) .with(Csrf::new()); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/poem/custom-error/src/main.rs b/examples/poem/custom-error/src/main.rs index 269c1366e8..7f7f0d754d 100644 --- a/examples/poem/custom-error/src/main.rs +++ b/examples/poem/custom-error/src/main.rs @@ -31,7 +31,7 @@ async fn main() -> Result<(), std::io::Error> { tracing_subscriber::fmt::init(); let app = Route::new().at("/", get(hello)); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/poem/custom-extractor/src/main.rs b/examples/poem/custom-extractor/src/main.rs index 713a14c4a4..fee3290f87 100644 --- a/examples/poem/custom-extractor/src/main.rs +++ b/examples/poem/custom-extractor/src/main.rs @@ -31,7 +31,7 @@ async fn main() -> Result<(), std::io::Error> { tracing_subscriber::fmt::init(); let app = Route::new().at("/", get(index)); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/poem/embed-files/src/main.rs b/examples/poem/embed-files/src/main.rs index 11db4ab382..a4dd065ed2 100644 --- a/examples/poem/embed-files/src/main.rs +++ b/examples/poem/embed-files/src/main.rs @@ -19,7 +19,7 @@ async fn main() -> Result<(), std::io::Error> { let app = Route::new() .at("/", EmbeddedFileEndpoint::::new("index.html")) .nest("/files", EmbeddedFilesEndpoint::::new()); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/poem/graceful-shutdown/src/main.rs b/examples/poem/graceful-shutdown/src/main.rs index a4afbb863d..835af9e176 100644 --- a/examples/poem/graceful-shutdown/src/main.rs +++ b/examples/poem/graceful-shutdown/src/main.rs @@ -45,7 +45,7 @@ async fn main() -> Result<(), std::io::Error> { let app = Route::new().at("/", get(index)).at("/event", get(event)); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run_with_graceful_shutdown( app, async move { diff --git a/examples/poem/handling-404/src/main.rs b/examples/poem/handling-404/src/main.rs index 2188af875c..b93315be4c 100644 --- a/examples/poem/handling-404/src/main.rs +++ b/examples/poem/handling-404/src/main.rs @@ -24,7 +24,7 @@ async fn main() -> Result<(), std::io::Error> { .body("haha") }); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/poem/hello-world/src/main.rs b/examples/poem/hello-world/src/main.rs index 2cf6013a5e..59808f1c8e 100644 --- a/examples/poem/hello-world/src/main.rs +++ b/examples/poem/hello-world/src/main.rs @@ -15,7 +15,7 @@ async fn main() -> Result<(), std::io::Error> { tracing_subscriber::fmt::init(); let app = Route::new().at("/hello/:name", get(hello)).with(Tracing); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .name("hello-world") .run(app) .await diff --git a/examples/poem/i18n/src/main.rs b/examples/poem/i18n/src/main.rs index f766514c1d..f00928659e 100644 --- a/examples/poem/i18n/src/main.rs +++ b/examples/poem/i18n/src/main.rs @@ -51,7 +51,7 @@ async fn main() -> Result<(), std::io::Error> { .at("/welcome_hashmap/:name", get(welcome_hashmap)) .with(Tracing) .data(resources); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .name("hello-world") .run(app) .await diff --git a/examples/poem/json/src/main.rs b/examples/poem/json/src/main.rs index 7830aef222..724bb42cfa 100644 --- a/examples/poem/json/src/main.rs +++ b/examples/poem/json/src/main.rs @@ -22,7 +22,7 @@ async fn main() -> Result<(), std::io::Error> { tracing_subscriber::fmt::init(); let app = Route::new().at("/hello", post(hello)); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/poem/middleware/src/main.rs b/examples/poem/middleware/src/main.rs index b9327413da..9d840ee52b 100644 --- a/examples/poem/middleware/src/main.rs +++ b/examples/poem/middleware/src/main.rs @@ -50,7 +50,7 @@ async fn main() -> Result<(), std::io::Error> { tracing_subscriber::fmt::init(); let app = Route::new().at("/", get(index)).with(Log); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/poem/middleware_fn/src/main.rs b/examples/poem/middleware_fn/src/main.rs index 15aeacec2c..ceca503ed1 100644 --- a/examples/poem/middleware_fn/src/main.rs +++ b/examples/poem/middleware_fn/src/main.rs @@ -33,7 +33,7 @@ async fn main() -> Result<(), std::io::Error> { tracing_subscriber::fmt::init(); let app = Route::new().at("/", get(index)).around(log); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/poem/mongodb/src/main.rs b/examples/poem/mongodb/src/main.rs index 066485aff4..15c21a1d2f 100644 --- a/examples/poem/mongodb/src/main.rs +++ b/examples/poem/mongodb/src/main.rs @@ -66,7 +66,7 @@ async fn main() -> io::Result<()> { .database("test"); let collection = mongodb.collection::("user"); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run( Route::new() .at("/user", get(get_users).post(create_user)) diff --git a/examples/poem/nested-routing/src/main.rs b/examples/poem/nested-routing/src/main.rs index e160fa3c57..2e9c059b0b 100644 --- a/examples/poem/nested-routing/src/main.rs +++ b/examples/poem/nested-routing/src/main.rs @@ -17,7 +17,7 @@ async fn main() -> Result<(), std::io::Error> { tracing_subscriber::fmt::init(); let app = Route::new().nest("/api", api()); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/poem/opentelemetry-jaeger/src/server1.rs b/examples/poem/opentelemetry-jaeger/src/server1.rs index bde8849e4d..fb6eb1d6b4 100644 --- a/examples/poem/opentelemetry-jaeger/src/server1.rs +++ b/examples/poem/opentelemetry-jaeger/src/server1.rs @@ -80,7 +80,7 @@ async fn main() -> Result<(), std::io::Error> { .with(OpenTelemetryMetrics::new()) .with(OpenTelemetryTracing::new(tracer)); - Server::new(TcpListener::bind("127.0.0.1:3001")) + Server::new(TcpListener::bind("0.0.0.0:3001")) .run(app) .await } diff --git a/examples/poem/opentelemetry-jaeger/src/server2.rs b/examples/poem/opentelemetry-jaeger/src/server2.rs index 701cc85a99..adc374bfb6 100644 --- a/examples/poem/opentelemetry-jaeger/src/server2.rs +++ b/examples/poem/opentelemetry-jaeger/src/server2.rs @@ -39,7 +39,7 @@ async fn main() -> Result<(), std::io::Error> { .with(OpenTelemetryMetrics::new()) .with(OpenTelemetryTracing::new(tracer)); - Server::new(TcpListener::bind("127.0.0.1:3002")) + Server::new(TcpListener::bind("0.0.0.0:3002")) .run(app) .await } diff --git a/examples/poem/redis-session/src/main.rs b/examples/poem/redis-session/src/main.rs index d053443dc5..0ae7237b03 100644 --- a/examples/poem/redis-session/src/main.rs +++ b/examples/poem/redis-session/src/main.rs @@ -26,7 +26,7 @@ async fn main() -> Result<(), std::io::Error> { CookieConfig::default().secure(false), RedisStorage::new(ConnectionManager::new(client).await.unwrap()), )); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/poem/sse/src/main.rs b/examples/poem/sse/src/main.rs index e9fab7ac9d..a70c9e47e1 100644 --- a/examples/poem/sse/src/main.rs +++ b/examples/poem/sse/src/main.rs @@ -44,7 +44,7 @@ async fn main() -> Result<(), std::io::Error> { tracing_subscriber::fmt::init(); let app = Route::new().at("/", get(index)).at("/event", get(event)); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/poem/static-files/src/main.rs b/examples/poem/static-files/src/main.rs index 12f5d67aab..4c0e466a36 100644 --- a/examples/poem/static-files/src/main.rs +++ b/examples/poem/static-files/src/main.rs @@ -11,7 +11,7 @@ async fn main() -> Result<(), std::io::Error> { "/", StaticFilesEndpoint::new("./poem/static-files/files").show_files_listing(), ); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/poem/tera-templating/src/main.rs b/examples/poem/tera-templating/src/main.rs index b5ce0e3ac6..782ef910da 100644 --- a/examples/poem/tera-templating/src/main.rs +++ b/examples/poem/tera-templating/src/main.rs @@ -33,7 +33,7 @@ fn hello(Path(name): Path) -> Result, poem::Error> { #[tokio::main] async fn main() -> Result<(), std::io::Error> { let app = Route::new().at("/hello/:name", get(hello)); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/poem/tls-reload/src/main.rs b/examples/poem/tls-reload/src/main.rs index 5c30548023..31b5acdf48 100644 --- a/examples/poem/tls-reload/src/main.rs +++ b/examples/poem/tls-reload/src/main.rs @@ -19,7 +19,7 @@ async fn main() -> Result<(), std::io::Error> { let app = Route::new().at("/", get(index)); - let listener = TcpListener::bind("127.0.0.1:3000").rustls(async_stream::stream! { + let listener = TcpListener::bind("0.0.0.0:3000").rustls(async_stream::stream! { loop { if let Ok(tls_config) = load_tls_config() { yield tls_config; diff --git a/examples/poem/tls/src/main.rs b/examples/poem/tls/src/main.rs index 1323caffb6..eefcd5c6e4 100644 --- a/examples/poem/tls/src/main.rs +++ b/examples/poem/tls/src/main.rs @@ -75,7 +75,7 @@ async fn main() -> Result<(), std::io::Error> { let app = Route::new().at("/", get(index)); - let listener = TcpListener::bind("127.0.0.1:3000") + let listener = TcpListener::bind("0.0.0.0:3000") .rustls(RustlsConfig::new().fallback(RustlsCertificate::new().key(KEY).cert(CERT))); Server::new(listener).run(app).await } diff --git a/examples/poem/tokio-metrics/src/main.rs b/examples/poem/tokio-metrics/src/main.rs index 976cc02219..bed226332b 100644 --- a/examples/poem/tokio-metrics/src/main.rs +++ b/examples/poem/tokio-metrics/src/main.rs @@ -34,7 +34,7 @@ async fn main() -> Result<(), std::io::Error> { .at("/a", get(a).with(metrics_a)) .at("/b", get(b).with(metrics_b)) .with(Tracing); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/poem/tonic/src/main.rs b/examples/poem/tonic/src/main.rs index cc6e37a875..08195bad33 100644 --- a/examples/poem/tonic/src/main.rs +++ b/examples/poem/tonic/src/main.rs @@ -39,7 +39,7 @@ async fn main() -> Result<(), std::io::Error> { .compat(), ); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/poem/tower-layer/src/main.rs b/examples/poem/tower-layer/src/main.rs index 519203f98f..cc6c759748 100644 --- a/examples/poem/tower-layer/src/main.rs +++ b/examples/poem/tower-layer/src/main.rs @@ -21,7 +21,7 @@ async fn main() -> Result<(), std::io::Error> { "/", get(hello).with(RateLimitLayer::new(5, Duration::from_secs(30)).compat()), ); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/poem/upload/src/main.rs b/examples/poem/upload/src/main.rs index 9e0405d1f4..0069c76e0d 100644 --- a/examples/poem/upload/src/main.rs +++ b/examples/poem/upload/src/main.rs @@ -50,7 +50,7 @@ async fn main() -> Result<(), std::io::Error> { tracing_subscriber::fmt::init(); let app = Route::new().at("/", get(index).post(upload)); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/examples/poem/websocket-chat/src/main.rs b/examples/poem/websocket-chat/src/main.rs index 4a86f90744..cbb058fc61 100644 --- a/examples/poem/websocket-chat/src/main.rs +++ b/examples/poem/websocket-chat/src/main.rs @@ -102,7 +102,7 @@ async fn main() -> Result<(), std::io::Error> { get(ws.data(tokio::sync::broadcast::channel::(32).0)), ); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/poem-grpc/README.md b/poem-grpc/README.md index da351dbeae..56caecd9d4 100644 --- a/poem-grpc/README.md +++ b/poem-grpc/README.md @@ -52,7 +52,7 @@ impl Greeter for GreeterService { #[tokio::main] async fn main() -> Result<(), std::io::Error> { let route = RouteGrpc::new().add_service(GreeterServer::new(GreeterService)); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(route) .await } diff --git a/poem-openapi/README.md b/poem-openapi/README.md index 0fe19027d8..21ae40b74d 100644 --- a/poem-openapi/README.md +++ b/poem-openapi/README.md @@ -98,7 +98,7 @@ async fn main() -> Result<(), std::io::Error> { let ui = api_service.swagger_ui(); let app = Route::new().nest("/api", api_service).nest("/", ui); - poem::Server::new(TcpListener::bind("127.0.0.1:3000")) + poem::Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/poem-openapi/src/lib.rs b/poem-openapi/src/lib.rs index fd4fb4dca4..5aa1054f50 100644 --- a/poem-openapi/src/lib.rs +++ b/poem-openapi/src/lib.rs @@ -61,7 +61,7 @@ //! let app = Route::new().nest("/", api_service).nest("/docs", ui); //! //! # tokio::runtime::Runtime::new().unwrap().block_on(async { -//! Server::new(TcpListener::bind("127.0.0.1:3000")) +//! Server::new(TcpListener::bind("0.0.0.0:3000")) //! .run(app) //! .await; //! # }); diff --git a/poem/README.md b/poem/README.md index 42dacf821a..ffd27a88e7 100644 --- a/poem/README.md +++ b/poem/README.md @@ -95,7 +95,7 @@ fn hello(Path(name): Path) -> String { #[tokio::main] async fn main() -> Result<(), std::io::Error> { let app = Route::new().at("/hello/:name", get(hello)); - Server::new(TcpListener::bind("127.0.0.1:3000")) + Server::new(TcpListener::bind("0.0.0.0:3000")) .run(app) .await } diff --git a/poem/src/lib.rs b/poem/src/lib.rs index d2eda3ade9..f7c587bff6 100644 --- a/poem/src/lib.rs +++ b/poem/src/lib.rs @@ -25,7 +25,7 @@ //! #[tokio::main] //! async fn main() -> Result<(), std::io::Error> { //! let app = Route::new().at("/hello/:name", get(hello)); -//! Server::new(TcpListener::bind("127.0.0.1:3000")) +//! Server::new(TcpListener::bind("0.0.0.0:3000")) //! .run(app) //! .await //! } diff --git a/poem/src/listener/mod.rs b/poem/src/listener/mod.rs index 06552939da..2e59598ca4 100644 --- a/poem/src/listener/mod.rs +++ b/poem/src/listener/mod.rs @@ -143,7 +143,7 @@ pub trait Listener: Send { /// ``` /// use poem::listener::{Listener, TcpListener}; /// - /// let listener = TcpListener::bind("127.0.0.1:80").combine(TcpListener::bind("127.0.0.1:81")); + /// let listener = TcpListener::bind("0.0.0.0:80").combine(TcpListener::bind("0.0.0.0:81")); /// ``` #[must_use] fn combine(self, other: T) -> Combined diff --git a/poem/src/listener/rustls.rs b/poem/src/listener/rustls.rs index 88d08c4cd0..7eeba2a3de 100644 --- a/poem/src/listener/rustls.rs +++ b/poem/src/listener/rustls.rs @@ -196,7 +196,7 @@ impl RustlsConfig { /// /// let config = /// RustlsConfig::new().fallback(RustlsCertificate::new().cert(cert_bytes).key(key_bytes)); - /// let listener = TcpListener::bind("127.0.0.1:3000").rustls(config); + /// let listener = TcpListener::bind("0.0.0.0:3000").rustls(config); /// ``` pub fn fallback(mut self, certificate: RustlsCertificate) -> Self { self.fallback = Some(certificate);