Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In the examples, listen on 0.0.0.0 instead of 127.0.0.1 #664 #672

Merged
merged 2 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/grpc/helloworld/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion examples/grpc/middleware/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion examples/grpc/routeguide/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion examples/openapi/auth-apikey/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/openapi/auth-multiple/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/openapi/custom-payload/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion examples/openapi/poem-middleware/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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(())
Expand Down
2 changes: 1 addition & 1 deletion examples/openapi/uniform-response/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/openapi/upload/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions examples/poem/combined-listeners/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion examples/poem/handling-404/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/poem/i18n/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/poem/json/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions examples/poem/mongodb/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ async fn main() -> io::Result<()> {
}
tracing_subscriber::fmt::init();

let mongodb = Client::with_uri_str("mongodb://127.0.0.1:27017")
let mongodb = Client::with_uri_str("mongodb://0.0.0.0:27017")
byte-sized-emi marked this conversation as resolved.
Show resolved Hide resolved
.await
.unwrap()
.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))
Expand Down
2 changes: 1 addition & 1 deletion examples/poem/nested-routing/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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
}
Loading
Loading