pub struct HttpServerBuilder { /* private fields */ }Expand description
Builder for HttpServer.
Implementations§
Source§impl HttpServerBuilder
impl HttpServerBuilder
Sourcepub fn new(config: HttpServerConfig, cancel: CancellationToken) -> Self
pub fn new(config: HttpServerConfig, cancel: CancellationToken) -> Self
Create a new builder.
Sourcepub fn with_router(self, router: Router) -> Self
pub fn with_router(self, router: Router) -> Self
Merge an axum Router into the server.
Sourcepub fn with_middleware_stack(self, middleware: HttpMiddlewareStack) -> Self
pub fn with_middleware_stack(self, middleware: HttpMiddlewareStack) -> Self
Replace the ordered middleware stack.
Sourcepub fn with_logging_transform<F>(self, transform: F) -> Self
pub fn with_logging_transform<F>(self, transform: F) -> Self
Append a logging-phase transform.
Sourcepub fn with_auth_transform<F>(self, transform: F) -> Self
pub fn with_auth_transform<F>(self, transform: F) -> Self
Append an auth-phase transform.
Sourcepub fn with_validation_transform<F>(self, transform: F) -> Self
pub fn with_validation_transform<F>(self, transform: F) -> Self
Append a validation-phase transform.
Sourcepub fn with_metrics_transform<F>(self, transform: F) -> Self
pub fn with_metrics_transform<F>(self, transform: F) -> Self
Append a metrics-phase transform.
Sourcepub fn with_cors(self) -> AppResult<Self>
pub fn with_cors(self) -> AppResult<Self>
Apply CORS from the server config (no-op if cors is None).
§Errors
Returns an error when the configured CORS policy contains invalid origins, methods, headers, or max-age values.
Sourcepub fn with_security_headers(self) -> AppResult<Self>
pub fn with_security_headers(self) -> AppResult<Self>
Add secure response headers using the default security policy.
§Errors
Returns an error if the default security policy cannot be built (should never happen in practice — this is a programming error guard).
Sourcepub fn with_security_headers_config(
self,
config: SecurityHeadersConfig,
) -> AppResult<Self>
pub fn with_security_headers_config( self, config: SecurityHeadersConfig, ) -> AppResult<Self>
Add secure response headers using an explicit security policy.
§Errors
Returns an error when the supplied policy is invalid.
Sourcepub fn build(self) -> AppResult<HttpServer>
pub fn build(self) -> AppResult<HttpServer>
Consume the builder and produce an HttpServer.
§Errors
Returns an error when baseline transport middleware configuration is invalid.
Auto Trait Implementations§
impl !RefUnwindSafe for HttpServerBuilder
impl !UnwindSafe for HttpServerBuilder
impl Freeze for HttpServerBuilder
impl Send for HttpServerBuilder
impl Sync for HttpServerBuilder
impl Unpin for HttpServerBuilder
impl UnsafeUnpin for HttpServerBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request