Skip to main content

Route

Struct Route 

Source
pub struct Route {
    pub name: String,
    pub host: String,
    pub path: String,
    pub match_paths: Vec<String>,
    pub service: String,
    pub methods: Vec<String>,
    pub header: BTreeMap<String, String>,
    pub query: BTreeMap<String, String>,
    pub plugins: Vec<ConfiguredPlugin>,
    pub is_auth: bool,
    pub auth_white_list: Vec<String>,
}

Fields§

§name: String

路由名称

§host: String

Host,可选,* 代表不限制。 支持泛域名,格式为 *.example.com,通配符只能出现在域名开头。

§path: String

路径,支持通配符,必须以 / 开头,全局唯一。 同一域名下的路径不能存在冲突,如 /api/*/api/** 就是冲突的路径,在控制台保存时需要校验。 所有为 * 的域名下的路径也不能冲突。

§match_paths: Vec<String>

转换后的匹配路径。 由于路径匹配组件使用的是matchit,格式为/xxx/{*any}, 它不符合常用的/api/**的格式,而path储存的是常用格式, 所以这里需要做一次转换。

§service: String

需要路由到的服务ID,例如 user-service

§methods: Vec<String>

请求方法:GET | POST | PUT | DELETE | PATCH | OPTIONS | HEAD 支持配置多个。当为空数组时表示不限制。 不参与路由唯一性验证。

§header: BTreeMap<String, String>

header匹配条件。 当存在多个时,所有条件都匹配时才算匹配成功。 不参与路由唯一性验证。

§query: BTreeMap<String, String>

query匹配条件 当存在多个时,所有条件都匹配时才算匹配成功。 不参与路由唯一性验证。

§plugins: Vec<ConfiguredPlugin>

插件

§is_auth: bool

是否开启鉴权。 启用后,需要在控制台的“密钥管理”处创建API Key, 并通过请求头 X-Aiway-Authorization 传入,作为网关的鉴权凭证。

§auth_white_list: Vec<String>

鉴权路径白名单

Implementations§

Source§

impl Route

Source

pub fn get_service(&self) -> &String

Source

pub fn to_match_keys(&self) -> Vec<String>

host + path作为匹配的key

Trait Implementations§

Source§

impl Clone for Route

Source§

fn clone(&self) -> Route

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Route

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Route

Source§

fn default() -> Route

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Route

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Route

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,