HTTP Servers
poem
Running an Ulo application inside a poem server with ulo-http-poem.
ulo-http-poem is a native embedding: the adapter implements poem::Endpoint, nested under a path or used as the fallback. It builds against poem 3.1 with the server feature.
Mounting
use poem::listener::TcpListener;
use ulo::App;
let server = ulo_http_poem::Embedded::new().nested_at("/api");
let embedded = server.handle();
let app = App::builder(AppModule).runtime(ulo_runtime_tokio::Tokio::current()).wire()?.connect().await?.bind(server).listen().await?;
let route = poem::Route::new().nest("/api", ulo_http_poem::endpoint(&embedded));
ulo_http_poem::run(app, &embedded, poem::Server::new(TcpListener::bind("0.0.0.0:3000")), route, ulo_runtime_tokio::shutdown_signal()).await?;(From the crate documentation of ulo-http-poem.)
Route::nest strips the prefix, which the adapter relies on. Mounting the endpoint with Route::at("/api/*path", ..) leaves the prefix on the path and is not supported. run calls run_with_graceful_shutdown with the app's drain window.
What it declares
- The peer address from
remote_addr. - WebSocket upgrades, so gateways on the HTTP port work.
- Host extensions from
Request::extensions. - No miss forwarding and no TLS information.
- No close signal on HTTP/1.1. poem awaits hyper's connection again after the peer closes it, so an HTTP/1.1 call runs on to its answer. The adapter declares
without_pending_close. A reset HTTP/2 stream cancels the call withDisconnected. - Streamed bodies. A dropped response body is observed at the next failed write.
OriginalPathis a built-in forward, read fromreq.original_uri(). The app's response,Routingincluded, keeps its extensions in poem's response, where middleware around the endpoint reads them.