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) -> HttpApp

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) -> HttpApp

Source

pub const fn with_unverified_security_schemes(self, allow: bool) -> HttpApp

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) -> HttpApp

Mounts precompiled OpenAPI JSON and UI assets.

Source

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

Registers runtime-neutral HTTP middleware for every request.

Source

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

Registers shared middleware state for every request.

Source

pub fn with_scoped_middleware( self, scope: MiddlewareScope, middleware: impl HttpMiddleware + 'static, ) -> HttpApp

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>, ) -> HttpApp

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

Source

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

Registers an application-level handler for failure responses.

Source

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

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more