[][src]Struct amiya::Amiya

pub struct Amiya<Ex = ()> { /* fields omitted */ }

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]

pub fn new() -> Self[src]

Create a Amiya instance.

impl<Ex> Amiya<Ex> where
    Ex: Send + Sync + 'static, 
[src]

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]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,