pub struct HttpApp { /* private fields */ }Expand description
An owned, runtime-neutral HTTP application compiled from the operation graph.
Network adapters own this type so the router is compiled once and request dispatch stays independent from the selected socket runtime.
Implementations§
Source§impl HttpApp
impl HttpApp
Sourcepub fn new(app: ExecutableApp) -> Self
pub fn new(app: ExecutableApp) -> Self
Compiles the router for an owned application.
§Introspection contract
When the EMIT_VARIABLE environment variable (BLAZINGLY_EMIT) is
set to openapi or routes, construction prints the OpenAPI
document or the operation table to stdout and terminates the process
with exit code 0 instead of returning, before any socket is served.
Every native serving path constructs an HttpApp, so
cargo blazingly openapi and cargo blazingly routes run an
unmodified application binary as a printer through this seam. The exit
inside a constructor is deliberate and is part of the CLI contract.
The document is rendered with OpenApiConfig::default; an
application’s own HttpApp::with_openapi configuration is not known
at construction time. Any other non-empty value terminates with exit
code 2, so a typo never falls through to serving. An unset or empty
variable leaves construction unaffected, and TestApp never
consults the variable.
pub const fn with_max_body_bytes(self, max_body_bytes: usize) -> Self
Sourcepub const fn with_unverified_security_schemes(self, allow: bool) -> Self
pub const fn with_unverified_security_schemes(self, allow: bool) -> Self
Allows operations that declare a security scheme to run without a
registered verifier. Defaults to false.
Passing true disables the fail-closed guard: a declared scheme then
only documents the contract and this adapter performs no
authentication. Enable it for tests, or for an application that
deliberately enforces the scheme outside this dispatch path.
Sourcepub async fn startup(&self) -> Result<(), DependencyError>
pub async fn startup(&self) -> Result<(), DependencyError>
Sourcepub async fn shutdown(&self) -> Result<(), DependencyError>
pub async fn shutdown(&self) -> Result<(), DependencyError>
Runs compiled application shutdown hooks.
§Errors
Returns the first cleanup failure after all shutdown hooks have run.
Sourcepub fn with_openapi(self, config: OpenApiConfig) -> Self
pub fn with_openapi(self, config: OpenApiConfig) -> Self
Mounts precompiled OpenAPI JSON and UI assets.
Sourcepub fn with_middleware(self, middleware: impl HttpMiddleware + 'static) -> Self
pub fn with_middleware(self, middleware: impl HttpMiddleware + 'static) -> Self
Registers runtime-neutral HTTP middleware for every request.
Registers shared middleware state for every request.
Sourcepub fn with_scoped_middleware(
self,
scope: MiddlewareScope,
middleware: impl HttpMiddleware + 'static,
) -> Self
pub fn with_scoped_middleware( self, scope: MiddlewareScope, middleware: impl HttpMiddleware + 'static, ) -> Self
Registers runtime-neutral HTTP middleware for one path prefix or operation selection.
Registers shared middleware state for one path prefix or operation selection.
Sourcepub fn with_error_handler(
self,
handler: impl HttpErrorHandler + 'static,
) -> Self
pub fn with_error_handler( self, handler: impl HttpErrorHandler + 'static, ) -> Self
Registers an application-level handler for failure responses.
Registers shared application-level error handler state.
pub async fn call(&self, request: Request) -> Response
pub async fn call_view(&self, request: &impl HttpRequestView) -> Response
pub async fn call_view_controlled( &self, request: &impl HttpRequestView, control: InvocationControl, ) -> Response
Sourcepub fn request_body_source(
&self,
method: HttpMethod,
target: &str,
) -> Option<InputSource>
pub fn request_body_source( &self, method: HttpMethod, target: &str, ) -> Option<InputSource>
Returns the compiled body source for a recognized request.
Native adapters use this before buffering a body so streaming operations can start as soon as the request head is validated.