#[non_exhaustive]pub struct Route {
pub name: String,
pub host: String,
pub path_prefix: String,
pub upstreams: Vec<String>,
pub strip_prefix: bool,
pub upstream_host: String,
pub selection: Selection,
}Expand description
One route: a match rule and an upstream pool.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: StringUnique name, used in metrics and logs. Letters, digits, _, -
and . only. fallback and unmatched are reserved.
host: StringHost to match: api.example.com or *.example.com. Empty: any
host. The match ignores case and the port.
path_prefix: StringPath prefix to match, on a segment boundary: /api matches /api
and /api/x, not /apix. Default: /.
upstreams: Vec<String>Upstream addresses, host:port. Hostnames resolve at boot.
strip_prefix: boolRemove path_prefix before the request goes upstream.
Default: false.
upstream_host: StringHost header for the upstream. Empty: keep the client Host.
selection: SelectionHow to pick an upstream. Default: round_robin.
Implementations§
Source§impl Route
impl Route
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
A route with name, the root prefix and no upstreams.
Sourcepub fn host(self, host: impl Into<String>) -> Self
pub fn host(self, host: impl Into<String>) -> Self
Match this host: api.example.com or *.example.com.
Sourcepub fn path_prefix(self, prefix: impl Into<String>) -> Self
pub fn path_prefix(self, prefix: impl Into<String>) -> Self
Match this path prefix.
Sourcepub const fn strip_prefix(self, strip: bool) -> Self
pub const fn strip_prefix(self, strip: bool) -> Self
Remove the prefix before the request goes upstream.
Sourcepub fn upstream_host(self, host: impl Into<String>) -> Self
pub fn upstream_host(self, host: impl Into<String>) -> Self
Send this Host header upstream.
Sourcepub fn validate(&self) -> Result<(), ConfigError>
pub fn validate(&self) -> Result<(), ConfigError>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Route
impl<'de> Deserialize<'de> for Route
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Route
impl StructuralPartialEq for Route
Auto Trait Implementations§
impl Forget for Route
impl Freeze for Route
impl RefUnwindSafe for Route
impl Send for Route
impl Sync for Route
impl Unpin for Route
impl UnsafeUnpin for Route
impl UnwindSafe for Route
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> ⓘ
impl<T> JsonSink for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Scoped for T
impl<T> Scoped for T
Source§fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
ScopeQuery for this type. Resolves the
registered scope at .load() time, not here.