Struct writium::namespace::Namespace
[−]
[src]
pub struct Namespace { /* fields omitted */ }
Namespace
bind with apis and forms an intermediate layer of API. It self
doesn't do a thing but it will.
It's name is used to distinguish with other peer APIs and all the sub-API
will not see the namespace name segments in the request. If you want the
namespace it self to have some functionalities, you need to create a sub-API
and name it &[]
. But such design is not recommended because it sometimes
will make the API work in a weird way, especially when path variables are
involved, i.e. the trailing part of the path is used as a variable.
Methods
impl Namespace
[src]
pub fn new(name: &'static [&'static str]) -> Namespace
[src]
pub fn with_api<A: Api>(self, api: A) -> Namespace
[src]
pub fn bind<A: Api>(&mut self, api: A)
[src]
Trait Implementations
impl Clone for Namespace
[src]
fn clone(&self) -> Namespace
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Api for Namespace
[src]
fn name(&self) -> &[&str]
[src]
Name of API. It identifies an API and allow Writium to route by URL path segments. Read more
fn route(&self, req: &mut Request) -> ApiResult
[src]
The route function here will ask every sub-API to make an response in binding order. The collection routing is short-circuiting, i.e., once a sub-API responded, the response is returned and the following it won't check the remaining unchecked sub-apis.