#HTTP Ingress & Routing

Version: 0.33.0 Updated: 2026-03-15 Applies to: ranvier-http Category: Deep Dives


Build type-safe, explicit HTTP boundaries with the Router DSL.

#Router DSL

  • Grouping: Bundle related routes under a shared prefix (e.g., /api/v1).
  • Macros: Use ranvier_router! to define complex routing tables with less boilerplate.
  • Composition: Nest groups to reflect nested API structures.

#Type-Safe Routing

  • Path Params: Extract variables from URI (e.g., /user/:id) into types.
  • Method Guard: Restrict nodes to GET, POST, PUT, DELETE, etc.
  • Explicit Flow: No hidden middleware magic; transformations are standard Axon steps.

#Body Handling

Feature Description
JsonBody<T> Native JSON request/response with type validation
Streaming Handle large payloads without loading everything into memory
SSE Built-in EventSource stream bridging for text/event-stream
Multipart Parse multipart/form-data file uploads with size limits
Limits Configure body size limits per route or globally

#Quickstart

Ranvier::http()
  .bind("0.0.0.0:3000")
  .route("/", hello_axon)
  .route_group("/api/v1", |v1| {
      v1.route("/users", user_axon)
  })
  .run().await?;

#Workflows

  1. Define a Schematic for your API logic.
  2. Bind the Axon to a URI and HTTP Method.
  3. Add Middleware Layers (CORS, Auth) to specific groups.
  4. Extract path parameters using the Path<T> extractor.

#Key Types

Type Description
HttpIngress Primary builder for configuring the HTTP server and routing table
RouteGroup Container for organizing routes with shared prefixes and layers
JsonBody<T> Wrapper for type-safe JSON extraction and serialization
Path<T> Extractor for capturing segments from the request URI
Multipart Multipart form-data extractor for file uploads (feature-gated: multer)