Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
sunli829 committed Nov 19, 2023
2 parents ed5fea6 + 7c9cff6 commit 3950b8a
Show file tree
Hide file tree
Showing 104 changed files with 785 additions and 259 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
- name: Cache Rust
uses: Swatinem/rust-cache@v2
- name: Install Protoc
if: matrix.package.name == 'poem-grpc'
if: matrix.package.name == 'poem-grpc' || matrix.package.name == 'poem-openapi'
uses: arduino/setup-protoc@v1

# Do tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Install Protoc
if: matrix.package.name == 'poem-grpc'
if: matrix.package.name == 'poem-grpc' || matrix.package.name == 'poem-openapi'
uses: arduino/setup-protoc@v1
- name: Get Version
working-directory: ${{ matrix.package.path }}
Expand Down
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ repository = "https://github.com/poem-web/poem"
rust-version = "1.64"

[workspace.dependencies]
poem = { path = "poem", version = "1.3.58", default-features = false }
poem-derive = { path = "poem-derive", version = "1.3.58" }
poem-openapi-derive = { path = "poem-openapi-derive", version = "3.0.4" }
poem-grpc-build = { path = "poem-grpc-build", version = "0.2.22" }
poem = { path = "poem", version = "1.3.59", default-features = false }
poem-derive = { path = "poem-derive", version = "1.3.59" }
poem-openapi-derive = { path = "poem-openapi-derive", version = "3.0.6" }
poem-grpc-build = { path = "poem-grpc-build", version = "0.2.23" }

proc-macro-crate = "1.1.0"
proc-macro-crate = "2.0.0"
proc-macro2 = "1.0.29"
quote = "1.0.9"
syn = { version = "2.0" }
Expand All @@ -36,7 +36,7 @@ thiserror = "1.0.30"
regex = "1.5.5"
mime = "0.3.16"
tracing = "0.1.36"
chrono = { version = "0.4.19", default-features = false }
chrono = { version = "0.4.31", default-features = false }
bytes = "1.1.0"
futures-util = "0.3.17"
tokio-stream = "0.1.8"
Expand Down
5 changes: 3 additions & 2 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
members = ["poem/*", "openapi/*", "grpc/*"]

[workspace.package]
Expand All @@ -14,10 +15,10 @@ poem-lambda = { path = "../poem-lambda" }
poem-grpc-build = { path = "../poem-grpc-build" }

tokio = "1.17.0"
tracing-subscriber = { version ="0.3.9", features = ["env-filter"] }
tracing-subscriber = { version = "0.3.9", features = ["env-filter"] }
serde_json = "1.0.68"
serde = { version = "1.0.140", features = ["derive"] }
mime = "0.3.16"
futures-util = "0.3.21"
tokio-stream = "0.1.8"
prost = "0.11.0"
prost = "0.12.0"
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
Loading

0 comments on commit 3950b8a

Please sign in to comment.