Struct salvo_oapi::server::Server
source · #[non_exhaustive]pub struct Server {
pub url: String,
pub description: Option<String>,
pub variables: ServerVariables,
}Expand description
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.url: StringTarget url of the Server. It can be valid http url or relative path.
Url also supports variable substitution with {variable} syntax. The substitutions
then can be configured with Server::variables map.
description: Option<String>Optional description describing the target server url. Description supports markdown syntax.
variables: ServerVariablesOptional map of variable name and its substitution value used in Server::url.
Implementations§
source§impl Server
impl Server
sourcepub fn new<S: Into<String>>(url: S) -> Self
pub fn new<S: Into<String>>(url: S) -> Self
Construct a new Server with given url. Url can be valid http url or context path of the url.
If url is valid http url then all path operation request’s will be forwarded to the selected Server.
If url is path of url e.g. /api/v1 then the url will be appended to the servers address and the
operations will be forwarded to location server address + url.
Examples
Create new server with url path.
Server::new("/api/v1");Create new server with alternative server.
Server::new("https://alternative.pet-api.test/api/v1");sourcepub fn description<S: Into<String>>(self, description: S) -> Self
pub fn description<S: Into<String>>(self, description: S) -> Self
Add or change description of the Server.
sourcepub fn add_variable<N: Into<String>, V: Into<ServerVariable>>(
self,
name: N,
variable: V
) -> Self
pub fn add_variable<N: Into<String>, V: Into<ServerVariable>>( self, name: N, variable: V ) -> Self
Add parameter to Server which is used to substitute values in Server::url.
nameDefines name of the parameter which is being substituted within the url. If url has{username}substitution then the name should beusername.parameterUseServerVariableto define how the parameter is being substituted within the url.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Server
impl<'de> Deserialize<'de> for Server
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>,
source§impl Ord for Server
impl Ord for Server
source§impl PartialEq<Server> for Server
impl PartialEq<Server> for Server
source§impl PartialOrd<Server> for Server
impl PartialOrd<Server> for Server
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moreimpl Eq for Server
impl StructuralEq for Server
impl StructuralPartialEq for Server
Auto Trait Implementations§
impl RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl UnwindSafe for Server
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<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.