[−][src]Struct amiya::Amiya
Amiya HTTP Server.
Amiya itself also implement the Middleware
trait and can be added to another Amiya
instance, see examples/subapp.rs
for a example.
Implementations
impl<Ex> Amiya<Ex>
[src]
impl<Ex> Amiya<Ex> where
Ex: Send + Sync + 'static,
[src]
Ex: Send + Sync + 'static,
pub fn uses<M: Middleware<Ex> + 'static>(self, middleware: M) -> Self
[src]
Add a middleware to the end, middleware will be executed as the order of be added.
You can create middleware by implement the Middleware
trait
for your custom type or use the m
macro to convert a async func or closure.
Examples
use amiya::m; amiya::new().uses(m!(ctx => ctx.next().await));
use amiya::{m, middleware::Router}; let router = Router::new().endpoint().get(m!( ctx => ctx.resp.set_body("Hello world!"); )); amiya::new().uses(router);
impl<Ex> Amiya<Ex> where
Ex: Default + Send + Sync + 'static,
[src]
Ex: Default + Send + Sync + 'static,
pub async fn listen<A: AsyncToSocketAddrs + Debug>(self, addr: A) -> Result<()>
[src]
Run Amiya server on given addr
Examples
amiya::new().listen("127.0.0.1:8080");
amiya::new().listen(("127.0.0.1", 8080));
use std::net::Ipv4Addr; amiya::new().listen((Ipv4Addr::new(127, 0, 0, 1), 8080));
use std::net::{SocketAddrV4, Ipv4Addr}; let socket = SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 8080); amiya::new().listen(socket);
amiya::new().listen("[::]:8080");
Trait Implementations
impl<Ex> Default for Amiya<Ex>
[src]
impl<Ex: Send + Sync + 'static> Middleware<Ex> for Amiya<Ex>
[src]
Auto Trait Implementations
impl<Ex = ()> !RefUnwindSafe for Amiya<Ex>
impl<Ex> Send for Amiya<Ex>
impl<Ex> Sync for Amiya<Ex>
impl<Ex> Unpin for Amiya<Ex>
impl<Ex = ()> !UnwindSafe for Amiya<Ex>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,