pub struct ServerWrappers {
pub metrics_enabled: bool,
pub prometheus: PrometheusMetrics,
pub cors: Cors,
}Expand description
Represents the middleware wrappers applied to the HTTP server.
This structure groups cross-cutting concerns that are attached to the request/response pipeline, such as metrics collection and CORS handling.
§Fields
-
metrics_enabled: Indicates whether Prometheus metrics are exposed and collected. -
prometheus: Configuration and instance responsible for exporting Prometheus metrics. -
cors: Cross-Origin Resource Sharing (CORS) configuration applied to incoming requests.
§Usage
This struct is typically initialized during server bootstrap and injected into the HTTP server builder to register middleware components.
The rust_microservice::create_server_wrappers function can be used to create an instance of
this struct.
§Example
use rust_microservice::{server_wrappers, ServerWrappers, settings::Settings};
let settings = Settings::new("./config.toml")
.unwrap_or_else(|e| panic!("Failed to load settings: {e}"));
let wrappers = server_wrappers(&settings).unwrap();
Fields§
§metrics_enabled: bool§prometheus: PrometheusMetrics§cors: CorsAuto Trait Implementations§
impl Freeze for ServerWrappers
impl !RefUnwindSafe for ServerWrappers
impl !Send for ServerWrappers
impl !Sync for ServerWrappers
impl Unpin for ServerWrappers
impl UnsafeUnpin for ServerWrappers
impl !UnwindSafe for ServerWrappers
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
Mutably borrows from an owned value. Read more
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§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>
Wrap the input message
T in a tonic::Request