Skip to content

Commit

Permalink
In the examples, listen on 0.0.0.0 instead of 127.0.0.1 #664 (#672)
Browse files Browse the repository at this point in the history
* In the examples, listen on 0.0.0.0 instead of 127.0.0.1 #664

* Fix accidentally replaced ip's
byte-sized-emi authored Nov 18, 2023
1 parent 7542061 commit 2413236
Showing 62 changed files with 64 additions and 64 deletions.
2 changes: 1 addition & 1 deletion examples/grpc/helloworld/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/grpc/jsoncodec/src/main.rs
Original file line number Diff line number Diff line change
@@ -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))
2 changes: 1 addition & 1 deletion examples/grpc/middleware/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/grpc/reflection/src/main.rs
Original file line number Diff line number Diff line change
@@ -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(
2 changes: 1 addition & 1 deletion examples/grpc/routeguide/src/main.rs
Original file line number Diff line number Diff line change
@@ -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 {
2 changes: 1 addition & 1 deletion examples/openapi/auth-apikey/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/openapi/auth-basic/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/openapi/auth-github/src/main.rs
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion examples/openapi/auth-multiple/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/openapi/combined-apis/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/openapi/content-type-accept/src/main.rs
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion examples/openapi/custom-payload/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/openapi/generics/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/openapi/hello-world/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/openapi/log-with-operation-id/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/openapi/poem-extractor/src/main.rs
Original file line number Diff line number Diff line change
@@ -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))
2 changes: 1 addition & 1 deletion examples/openapi/poem-middleware/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/openapi/sse/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/openapi/todos/src/main.rs
Original file line number Diff line number Diff line change
@@ -158,7 +158,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.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(())
2 changes: 1 addition & 1 deletion examples/openapi/uniform-response/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/openapi/union/src/main.rs
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion examples/openapi/upload/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/openapi/users-crud/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/async-graphql/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/auth/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/basic-auth/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/catch-panic/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions examples/poem/combined-listeners/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/cookie-session/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/csrf/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/custom-error/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/custom-extractor/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/embed-files/src/main.rs
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ async fn main() -> Result<(), std::io::Error> {
let app = Route::new()
.at("/", EmbeddedFileEndpoint::<Files>::new("index.html"))
.nest("/files", EmbeddedFilesEndpoint::<Files>::new());
Server::new(TcpListener::bind("127.0.0.1:3000"))
Server::new(TcpListener::bind("0.0.0.0:3000"))
.run(app)
.await
}
2 changes: 1 addition & 1 deletion examples/poem/graceful-shutdown/src/main.rs
Original file line number Diff line number Diff line change
@@ -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 {
2 changes: 1 addition & 1 deletion examples/poem/handling-404/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/hello-world/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion examples/poem/i18n/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion examples/poem/json/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/middleware/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/middleware_fn/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/mongodb/src/main.rs
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ async fn main() -> io::Result<()> {
.database("test");
let collection = mongodb.collection::<Document>("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))
2 changes: 1 addition & 1 deletion examples/poem/nested-routing/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/opentelemetry-jaeger/src/server1.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/opentelemetry-jaeger/src/server2.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/redis-session/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/sse/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/static-files/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/tera-templating/src/main.rs
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ fn hello(Path(name): Path<String>) -> Result<Html<String>, 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
}
2 changes: 1 addition & 1 deletion examples/poem/tls-reload/src/main.rs
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion examples/poem/tls/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/tokio-metrics/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/tonic/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/tower-layer/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/upload/src/main.rs
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion examples/poem/websocket-chat/src/main.rs
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@ async fn main() -> Result<(), std::io::Error> {
get(ws.data(tokio::sync::broadcast::channel::<String>(32).0)),
);

Server::new(TcpListener::bind("127.0.0.1:3000"))
Server::new(TcpListener::bind("0.0.0.0:3000"))
.run(app)
.await
}
2 changes: 1 addition & 1 deletion poem-grpc/README.md
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion poem-openapi/README.md
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion poem-openapi/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
//! # });
2 changes: 1 addition & 1 deletion poem/README.md
Original file line number Diff line number Diff line change
@@ -95,7 +95,7 @@ fn hello(Path(name): Path<String>) -> 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
}
2 changes: 1 addition & 1 deletion poem/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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
//! }
2 changes: 1 addition & 1 deletion poem/src/listener/mod.rs
Original file line number Diff line number Diff line change
@@ -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<T>(self, other: T) -> Combined<Self, T>
2 changes: 1 addition & 1 deletion poem/src/listener/rustls.rs
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 2413236

Please sign in to comment.