Struct arc_reactor::core::ArcReactor [−][src]
pub struct ArcReactor { /* fields omitted */ }The main server, the ArcReactor is where you mount your routes, middlewares and initiate the server.
#Examples
extern crate arc_reactor; extern crate tokio; use arc_reactor::core::ArcReactor; fn main() { let server = ArcReactor::default() .port(1234) .start() .expect("couldn't start server"); tokio::run(server); }
Methods
impl ArcReactor[src]
impl ArcReactorpub fn new() -> Self[src]
pub fn new() -> SelfCreates an instance of the server.
with a default port of 8080
pub fn port(self, port: i16) -> Self[src]
pub fn port(self, port: i16) -> SelfSets the port for the server to listen on and returns the instance.
pub fn tls(self, acceptor: TlsAcceptor) -> Self[src]
pub fn tls(self, acceptor: TlsAcceptor) -> Selfset the TlsAcceptor
check the examples folder for more info.
pub fn routes(self, routes: Router) -> Self[src]
pub fn routes(self, routes: Router) -> SelfMounts the Router on the ArcReactor.
pub fn service<S: ArcService + 'static>(self, service: S) -> Self[src]
pub fn service<S: ArcService + 'static>(self, service: S) -> Selfpub fn before<M>(self, before: M) -> Self where
M: MiddleWare<Request> + 'static, [src]
pub fn before<M>(self, before: M) -> Self where
M: MiddleWare<Request> + 'static, pub fn after<M>(self, after: M) -> Self where
M: MiddleWare<Response> + 'static, [src]
pub fn after<M>(self, after: M) -> Self where
M: MiddleWare<Response> + 'static, pub fn start(
self
) -> Result<impl Future<Item = (), Error = ()> + Send, Error>[src]
pub fn start(
self
) -> Result<impl Future<Item = (), Error = ()> + Send, Error>Binds the listener and returns a future representing the server this future should be spawned on the tokio runtime.
Panics
Calling this function will panic if: no routes are supplied, or it cannot start the main event loop.
Trait Implementations
impl Default for ArcReactor[src]
impl Default for ArcReactorAuto Trait Implementations
impl Send for ArcReactor
impl Send for ArcReactorimpl Sync for ArcReactor
impl Sync for ArcReactor