pub struct HttpIngress<R = ()> { /* private fields */ }Expand description
HTTP Ingress Circuit Builder.
Wires HTTP inputs to Ranvier Circuits. This is NOT a web server—it’s a circuit wiring tool.
Ingress is part of Schematic (separate layer: Ingress → Circuit → Egress)
Implementations§
Source§impl<R> HttpIngress<R>
impl<R> HttpIngress<R>
Sourcepub fn active_intervention(self) -> Self
pub fn active_intervention(self) -> Self
Enable active intervention endpoints (/_system/intervene/*).
These endpoints allow external tooling (like Ranvier Studio) to pause,
inspect, and forcefully resume or re-route in-flight workflow instances.
Sourcepub fn policy_registry(self, registry: PolicyRegistry) -> Self
pub fn policy_registry(self, registry: PolicyRegistry) -> Self
Attach a policy registry for hot-reloads.
Sourcepub fn on_start<F>(self, callback: F) -> Self
pub fn on_start<F>(self, callback: F) -> Self
Register a lifecycle callback invoked when the server starts listening.
Sourcepub fn on_shutdown<F>(self, callback: F) -> Self
pub fn on_shutdown<F>(self, callback: F) -> Self
Register a lifecycle callback invoked after graceful shutdown completes.
Sourcepub fn graceful_shutdown(self, timeout: Duration) -> Self
pub fn graceful_shutdown(self, timeout: Duration) -> Self
Configure graceful shutdown timeout for in-flight request draining.
Sourcepub fn config(self, config: &RanvierConfig) -> Self
pub fn config(self, config: &RanvierConfig) -> Self
Apply a RanvierConfig to this builder.
Reads server settings (bind address, shutdown timeout) from the config
and initializes telemetry if an OTLP endpoint is configured.
Logging should be initialized separately via config.init_logging().
Sourcepub fn timeout_layer(self, timeout: Duration) -> Self
pub fn timeout_layer(self, timeout: Duration) -> Self
Add built-in timeout middleware that returns 408 Request Timeout
when the inner service call exceeds timeout.
Sourcepub fn request_id_layer(self) -> Self
pub fn request_id_layer(self) -> Self
Add built-in request-id middleware.
Ensures x-request-id exists on request and response headers.
Sourcepub fn bus_injector<F>(self, injector: F) -> Self
pub fn bus_injector<F>(self, injector: F) -> Self
Register a request-context injector executed before each circuit run.
Use this to bridge adapter-layer context (request extensions/headers) into explicit Bus resources consumed by Transitions.
Sourcepub fn route_descriptors(&self) -> Vec<HttpRouteDescriptor>
pub fn route_descriptors(&self) -> Vec<HttpRouteDescriptor>
Export route metadata snapshot for external tooling.
Sourcepub fn serve_dir(
self,
route_prefix: impl Into<String>,
directory: impl Into<String>,
) -> Self
pub fn serve_dir( self, route_prefix: impl Into<String>, directory: impl Into<String>, ) -> Self
Mount a static directory under a path prefix.
Example: .serve_dir("/static", "./public").
Sourcepub fn spa_fallback(self, file_path: impl Into<String>) -> Self
pub fn spa_fallback(self, file_path: impl Into<String>) -> Self
Configure SPA fallback file for unmatched GET/HEAD routes.
Example: .spa_fallback("./public/index.html").
Sourcepub fn static_cache_control(self, cache_control: impl Into<String>) -> Self
pub fn static_cache_control(self, cache_control: impl Into<String>) -> Self
Override default Cache-Control for static responses.
Sourcepub fn compression_layer(self) -> Self
pub fn compression_layer(self) -> Self
Enable gzip response compression for static assets.
Sourcepub fn ws<H, Fut>(self, path: impl Into<String>, handler: H) -> Self
pub fn ws<H, Fut>(self, path: impl Into<String>, handler: H) -> Self
Register a WebSocket upgrade endpoint and session handler.
The handler receives:
- a
WebSocketConnectionimplementingEventSource/EventSink, - shared resources (
Arc<R>), - a connection-scoped
Buswith request injectors +WebSocketSessionContext.
Sourcepub fn health_endpoint(self, path: impl Into<String>) -> Self
pub fn health_endpoint(self, path: impl Into<String>) -> Self
Enable built-in health endpoint at the given path.
The endpoint returns JSON with status and check results.
If no checks are registered, status is always ok.
Sourcepub fn health_check<F, Fut, Err>(
self,
name: impl Into<String>,
check: F,
) -> Self
pub fn health_check<F, Fut, Err>( self, name: impl Into<String>, check: F, ) -> Self
Register an async health check used by /health and /ready probes.
Err values are converted to strings and surfaced in the JSON response.
Sourcepub fn readiness_liveness(
self,
readiness_path: impl Into<String>,
liveness_path: impl Into<String>,
) -> Self
pub fn readiness_liveness( self, readiness_path: impl Into<String>, liveness_path: impl Into<String>, ) -> Self
Enable readiness/liveness probe separation with explicit paths.
Sourcepub fn readiness_liveness_default(self) -> Self
pub fn readiness_liveness_default(self) -> Self
Enable readiness/liveness probes at /ready and /live.
Sourcepub fn route<Out, E>(
self,
path: impl Into<String>,
circuit: Axon<(), Out, E, R>,
) -> Selfwhere
Out: IntoResponse + Send + Sync + Serialize + DeserializeOwned + 'static,
E: Send + Sync + Serialize + DeserializeOwned + Debug + 'static,
pub fn route<Out, E>(
self,
path: impl Into<String>,
circuit: Axon<(), Out, E, R>,
) -> Selfwhere
Out: IntoResponse + Send + Sync + Serialize + DeserializeOwned + 'static,
E: Send + Sync + Serialize + DeserializeOwned + Debug + 'static,
Register a route with GET method.
Sourcepub fn route_method<Out, E>(
self,
method: Method,
path: impl Into<String>,
circuit: Axon<(), Out, E, R>,
) -> Selfwhere
Out: IntoResponse + Send + Sync + Serialize + DeserializeOwned + 'static,
E: Send + Sync + Serialize + DeserializeOwned + Debug + 'static,
pub fn route_method<Out, E>(
self,
method: Method,
path: impl Into<String>,
circuit: Axon<(), Out, E, R>,
) -> Selfwhere
Out: IntoResponse + Send + Sync + Serialize + DeserializeOwned + 'static,
E: Send + Sync + Serialize + DeserializeOwned + Debug + 'static,
pub fn route_method_with_error<Out, E, H>(
self,
method: Method,
path: impl Into<String>,
circuit: Axon<(), Out, E, R>,
error_handler: H,
) -> Selfwhere
Out: IntoResponse + Send + Sync + Serialize + DeserializeOwned + 'static,
E: Send + Sync + Serialize + DeserializeOwned + Debug + 'static,
H: Fn(&E) -> HttpResponse + Send + Sync + 'static,
pub fn get<Out, E>(
self,
path: impl Into<String>,
circuit: Axon<(), Out, E, R>,
) -> Selfwhere
Out: IntoResponse + Send + Sync + Serialize + DeserializeOwned + 'static,
E: Send + Sync + Serialize + DeserializeOwned + Debug + 'static,
pub fn get_with_error<Out, E, H>(
self,
path: impl Into<String>,
circuit: Axon<(), Out, E, R>,
error_handler: H,
) -> Selfwhere
Out: IntoResponse + Send + Sync + Serialize + DeserializeOwned + 'static,
E: Send + Sync + Serialize + DeserializeOwned + Debug + 'static,
H: Fn(&E) -> HttpResponse + Send + Sync + 'static,
pub fn post<Out, E>(
self,
path: impl Into<String>,
circuit: Axon<(), Out, E, R>,
) -> Selfwhere
Out: IntoResponse + Send + Sync + Serialize + DeserializeOwned + 'static,
E: Send + Sync + Serialize + DeserializeOwned + Debug + 'static,
pub fn put<Out, E>(
self,
path: impl Into<String>,
circuit: Axon<(), Out, E, R>,
) -> Selfwhere
Out: IntoResponse + Send + Sync + Serialize + DeserializeOwned + 'static,
E: Send + Sync + Serialize + DeserializeOwned + Debug + 'static,
pub fn delete<Out, E>(
self,
path: impl Into<String>,
circuit: Axon<(), Out, E, R>,
) -> Selfwhere
Out: IntoResponse + Send + Sync + Serialize + DeserializeOwned + 'static,
E: Send + Sync + Serialize + DeserializeOwned + Debug + 'static,
pub fn patch<Out, E>(
self,
path: impl Into<String>,
circuit: Axon<(), Out, E, R>,
) -> Selfwhere
Out: IntoResponse + Send + Sync + Serialize + DeserializeOwned + 'static,
E: Send + Sync + Serialize + DeserializeOwned + Debug + 'static,
pub fn post_with_error<Out, E, H>(
self,
path: impl Into<String>,
circuit: Axon<(), Out, E, R>,
error_handler: H,
) -> Selfwhere
Out: IntoResponse + Send + Sync + Serialize + DeserializeOwned + 'static,
E: Send + Sync + Serialize + DeserializeOwned + Debug + 'static,
H: Fn(&E) -> HttpResponse + Send + Sync + 'static,
pub fn put_with_error<Out, E, H>(
self,
path: impl Into<String>,
circuit: Axon<(), Out, E, R>,
error_handler: H,
) -> Selfwhere
Out: IntoResponse + Send + Sync + Serialize + DeserializeOwned + 'static,
E: Send + Sync + Serialize + DeserializeOwned + Debug + 'static,
H: Fn(&E) -> HttpResponse + Send + Sync + 'static,
pub fn delete_with_error<Out, E, H>(
self,
path: impl Into<String>,
circuit: Axon<(), Out, E, R>,
error_handler: H,
) -> Selfwhere
Out: IntoResponse + Send + Sync + Serialize + DeserializeOwned + 'static,
E: Send + Sync + Serialize + DeserializeOwned + Debug + 'static,
H: Fn(&E) -> HttpResponse + Send + Sync + 'static,
pub fn patch_with_error<Out, E, H>(
self,
path: impl Into<String>,
circuit: Axon<(), Out, E, R>,
error_handler: H,
) -> Selfwhere
Out: IntoResponse + Send + Sync + Serialize + DeserializeOwned + 'static,
E: Send + Sync + Serialize + DeserializeOwned + Debug + 'static,
H: Fn(&E) -> HttpResponse + Send + Sync + 'static,
Sourcepub fn fallback<Out, E>(self, circuit: Axon<(), Out, E, R>) -> Selfwhere
Out: IntoResponse + Send + Sync + Serialize + DeserializeOwned + 'static,
E: Send + Sync + Serialize + DeserializeOwned + Debug + 'static,
pub fn fallback<Out, E>(self, circuit: Axon<(), Out, E, R>) -> Selfwhere
Out: IntoResponse + Send + Sync + Serialize + DeserializeOwned + 'static,
E: Send + Sync + Serialize + DeserializeOwned + Debug + 'static,
Sourcepub async fn run(self, resources: R) -> Result<(), Box<dyn Error + Send + Sync>>
pub async fn run(self, resources: R) -> Result<(), Box<dyn Error + Send + Sync>>
Run the HTTP server with required resources.
Sourcepub fn into_raw_service(self, resources: R) -> RawIngressService<R>
pub fn into_raw_service(self, resources: R) -> RawIngressService<R>
Convert to a raw Hyper Service for integration with existing infrastructure.
This is the “escape hatch” per Discussion 193:
“Raw API는 Flat API의 탈출구다.”
§Example
let ingress = Ranvier::http()
.bind(":3000")
.route("/", circuit);
let raw_service = ingress.into_raw_service();
// Use raw_service with existing Hyper infrastructure