ulo
ulo
Documentation

Start here

Coming from NestJSNestJS topics, mapped

The model

Protocols

HTTP Serversulo-http-hyperTLSRuntimesEmbeddingaxumactix-websalvopoemrocketWriting a server crate

Integrations

Operating

Reference

HTTP Servers

rocket

Running an Ulo application inside a rocket server with ulo-http-rocket.

ulo-http-rocket is a native embedding: one catch-all rocket::route::Handler per method, mounted at a path. It builds against rocket 0.5 with the http2 feature. rocket 0.5 is on http 0.2, so the adapter converts at its edge.

Mounting

use ulo::App;

let server = ulo_http_rocket::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 rocket = rocket::build().mount("/api", ulo_http_rocket::routes(&embedded));
ulo_http_rocket::run(app, &embedded, rocket, ulo_runtime_tokio::shutdown_signal()).await?;

(From the crate documentation of ulo-http-rocket.)

run sets shutdown.ctrlc = false, no shutdown signals, and shutdown.grace to the app's drain window rounded up to the second. A rocket that fails to ignite makes the app shut down naming the error.

What it declares

  • The app strips the prefix. mount leaves the URI whole.
  • Miss forwarding. Embedded::on_miss(Miss::Forward) hands a request the app has no route for back to rocket with its unread Data. This is the only host that supports it.
  • Request bodies are buffered. rocket's Data must be read inside the handler, so the body is buffered under the embedding's max_body (2 MiB unset) once the app first reads it. A larger one is answered with the same 413 as elsewhere. A body the app never reads stays unread, which is what lets a forwarded miss go back to rocket intact.
  • No host extensions (use forward over rocket::Request) and no TLS information.
  • No close signal for a call in progress. rocket runs each request's handler in a task a closed connection or reset stream does not end. A handler gets no signal of it beyond a request body still arriving ending with an error. The adapter declares without_pending_close and without_pending_reset.
  • A dropped response body is observed at the next failed write.
  • Routing is stored in the request's local cache as an Option<Routing>, where a fairing's on_response reads it with req.local_cache(|| None::<Routing>). None means the app did not answer.
  • OriginalPath is a built-in forward, read from req.uri().path().

Limits

  • Drain window. Once hyper's server has finished, rocket's launch waits out its whole shutdown.grace if anything still holds the server, and a response the client abandoned during the drain leaves it waiting. A client that leaves mid-response during shutdown therefore makes the app's close take the whole drain window and no longer.
  • WebSocket requires HTTP/1.1 (RFC 6455 §4.2.1), and rocket 0.5 keeps no request's protocol version. The adapter hands the app every request as HTTP/1.1, so a gateway on the HTTP port answers an HTTP/1.0 upgrade request with 101, where every other host answers 400. A version-dependent rule in the app, such as HTTP/1.0 closing the connection by default, reads HTTP/1.1 here too.

poem

Running an Ulo application inside a poem server with ulo-http-poem.

Writing a server crate

The Backend, Listener and Embed traits a crate implements to serve Ulo over another HTTP stack, another runtime, or inside another framework.

On this page

MountingWhat it declaresLimits