Skip to main content

Gateway

Struct Gateway 

Source
pub struct Gateway<S> { /* private fields */ }
Expand description

A builder and configuration struct for the Gateway runtime.

Wraps a Router and allows attaching various handlers and configuration options. The into_service() method consumes this builder to produce the final Service.

Implementations§

Source§

impl<S> Gateway<S>

Source

pub fn new(router: Router<S>) -> Self

Creates a new Gateway wrapping the given Router and initialized with secure defaults.

Source

pub fn with_error_handler<F>(self, handler: F) -> Self
where F: Fn(&GatewayRequest, GatewayError) -> GatewayResponse + Send + Sync + 'static,

Sets the custom error handler.

Source

pub fn with_metadata<F>(self, annotator: F) -> Self
where F: Fn(&GatewayRequest) -> MetadataMap + Send + Sync + 'static,

Adds a metadata annotator.

Source

pub fn with_response_modifier<F>(self, modifier: F) -> Self
where F: Fn(&GatewayRequest, &mut GatewayResponse) + Send + Sync + 'static,

Adds a response modifier.

Source

pub fn with_incoming_header_matcher<F>(self, matcher: F) -> Self
where F: Fn(&str) -> Option<String> + Send + Sync + 'static,

Sets the incoming header matcher.

Source

pub fn with_outgoing_header_matcher<F>(self, matcher: F) -> Self
where F: Fn(&str) -> Option<String> + Send + Sync + 'static,

Sets the outgoing header matcher.

Source

pub fn with_unescaping_mode(self, mode: UnescapingMode) -> Self

Sets the unescaping mode.

Source

pub fn with_auth_verifier<F>(self, verifier: F) -> Self
where F: Fn(&GatewayRequest, &RouteMetadata) -> Result<(), GatewayError> + Send + Sync + 'static,

Sets the authentication verifier.

Source

pub fn with_metrics_recorder<F>(self, recorder: F) -> Self
where F: Fn(&GatewayRequest, &GatewayResult, Duration) + Send + Sync + 'static,

Sets the metrics recorder.

Source

pub fn with_tracing<Start, End>(self, start: Start, end: End) -> Self
where Start: Fn(&GatewayRequest) -> Box<dyn Any + Send> + Send + Sync + 'static, End: Fn(Box<dyn Any + Send>, &GatewayResult) + Send + Sync + 'static,

Sets tracing handlers.

Source

pub fn with_metadata_config(self, config: MetadataForwardingConfig) -> Self

Sets the metadata forwarding configuration.

Source

pub fn metadata_config(&self) -> &MetadataForwardingConfig

Returns a reference to the metadata configuration.

Source§

impl<S> Gateway<S>
where S: Service<GatewayRequest, Response = GatewayResponse, Error = GatewayError> + Clone + Send + 'static, S::Future: Send + 'static,

Source

pub fn into_service( self, ) -> BoxCloneService<GatewayRequest, GatewayResponse, GatewayError>

Consumes the Gateway configuration and returns a constructed tower::BoxCloneService.

This method assembles the complete middleware stack around the router.

Auto Trait Implementations§

§

impl<S> Freeze for Gateway<S>

§

impl<S> !RefUnwindSafe for Gateway<S>

§

impl<S> Send for Gateway<S>
where S: Send,

§

impl<S> Sync for Gateway<S>
where S: Sync,

§

impl<S> Unpin for Gateway<S>

§

impl<S> !UnwindSafe for Gateway<S>

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> 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> 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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
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<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