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
  • Loading branch information
byte-sized-emi authored Nov 18, 2023
1 parent 7542061 commit 2413236
Show file tree
Hide file tree
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
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
}
2 changes: 1 addition & 1 deletion examples/poem/mongodb/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
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
}
2 changes: 1 addition & 1 deletion examples/poem/opentelemetry-jaeger/src/server2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Loading

0 comments on commit 2413236

Please sign in to comment.