Skip to main content

HttpApp

Struct HttpApp 

Source
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

Source

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.

Source

pub const fn with_max_body_bytes(self, max_body_bytes: usize) -> Self

Source

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.

Source

pub async fn startup(&self) -> Result<(), DependencyError>

Runs compiled application startup hooks.

§Errors

Returns the first startup failure.

Source

pub async fn shutdown(&self) -> Result<(), DependencyError>

Runs compiled application shutdown hooks.

§Errors

Returns the first cleanup failure after all shutdown hooks have run.

Source

pub fn with_openapi(self, config: OpenApiConfig) -> Self

Mounts precompiled OpenAPI JSON and UI assets.

Source

pub fn with_middleware(self, middleware: impl HttpMiddleware + 'static) -> Self

Registers runtime-neutral HTTP middleware for every request.

Source

pub fn with_shared_middleware(self, middleware: Rc<dyn HttpMiddleware>) -> Self

Registers shared middleware state for every request.

Source

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.

Source

pub fn with_shared_scoped_middleware( self, scope: MiddlewareScope, middleware: Rc<dyn HttpMiddleware>, ) -> Self

Registers shared middleware state for one path prefix or operation selection.

Source

pub fn with_error_handler( self, handler: impl HttpErrorHandler + 'static, ) -> Self

Registers an application-level handler for failure responses.

Source

pub fn with_shared_error_handler( self, handler: Rc<dyn HttpErrorHandler>, ) -> Self

Registers shared application-level error handler state.

Source

pub async fn call(&self, request: Request) -> Response

Source

pub async fn call_view(&self, request: &impl HttpRequestView) -> Response

Source

pub async fn call_view_controlled( &self, request: &impl HttpRequestView, control: InvocationControl, ) -> Response

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> BackgroundExt for T

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ResponseExt for T

Source§

fn header( self, name: impl Into<String>, value: impl Into<String>, ) -> WithHeaders<Self>

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.