mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
export Handler
This commit is contained in:
parent
16ceb741b8
commit
427566b90d
@ -72,7 +72,6 @@ extern crate env_logger;
|
|||||||
use actix::*;
|
use actix::*;
|
||||||
use actix_web::*;
|
use actix_web::*;
|
||||||
|
|
||||||
|
|
||||||
struct MyWebSocket;
|
struct MyWebSocket;
|
||||||
|
|
||||||
/// Actor with http context
|
/// Actor with http context
|
||||||
@ -112,7 +111,8 @@ fn main() {
|
|||||||
.middleware(middlewares::Logger::default())
|
.middleware(middlewares::Logger::default())
|
||||||
// websocket route
|
// websocket route
|
||||||
.resource("/ws/", |r| r.get(|req| ws::start(req, MyWebSocket)))
|
.resource("/ws/", |r| r.get(|req| ws::start(req, MyWebSocket)))
|
||||||
.route_handler("/", StaticFiles::new("examples/static/", true)))
|
// static files
|
||||||
|
.route("/", StaticFiles::new("examples/static/", true)))
|
||||||
.serve::<_, ()>("127.0.0.1:8080").unwrap();
|
.serve::<_, ()>("127.0.0.1:8080").unwrap();
|
||||||
|
|
||||||
Arbiter::system().send(msgs::SystemExit(0));
|
Arbiter::system().send(msgs::SystemExit(0));
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
// dev specific
|
// dev specific
|
||||||
pub use task::Task;
|
pub use task::Task;
|
||||||
pub use route::Handler;
|
|
||||||
pub use pipeline::Pipeline;
|
pub use pipeline::Pipeline;
|
||||||
pub use recognizer::RouteRecognizer;
|
pub use recognizer::RouteRecognizer;
|
||||||
pub use channel::HttpChannel;
|
pub use channel::HttpChannel;
|
||||||
|
@ -82,7 +82,7 @@ pub use application::Application;
|
|||||||
pub use httprequest::{HttpRequest, UrlEncoded};
|
pub use httprequest::{HttpRequest, UrlEncoded};
|
||||||
pub use httpresponse::HttpResponse;
|
pub use httpresponse::HttpResponse;
|
||||||
pub use payload::{Payload, PayloadItem};
|
pub use payload::{Payload, PayloadItem};
|
||||||
pub use route::{Frame, Reply};
|
pub use route::{Frame, Reply, Handler};
|
||||||
pub use resource::Resource;
|
pub use resource::Resource;
|
||||||
pub use recognizer::Params;
|
pub use recognizer::Params;
|
||||||
pub use server::HttpServer;
|
pub use server::HttpServer;
|
||||||
|
@ -80,28 +80,28 @@ impl<S> Resource<S> where S: 'static {
|
|||||||
self.default = Box::new(WrapHandler::new(handler));
|
self.default = Box::new(WrapHandler::new(handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handler for `GET` method.
|
/// Register handler for `GET` method.
|
||||||
pub fn get<F, R>(&mut self, handler: F)
|
pub fn get<F, R>(&mut self, handler: F)
|
||||||
where F: Fn(HttpRequest<S>) -> R + 'static,
|
where F: Fn(HttpRequest<S>) -> R + 'static,
|
||||||
R: Into<Reply> + 'static, {
|
R: Into<Reply> + 'static, {
|
||||||
self.routes.insert(Method::GET, Box::new(WrapHandler::new(handler)));
|
self.routes.insert(Method::GET, Box::new(WrapHandler::new(handler)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handler for `POST` method.
|
/// Register handler for `POST` method.
|
||||||
pub fn post<F, R>(&mut self, handler: F)
|
pub fn post<F, R>(&mut self, handler: F)
|
||||||
where F: Fn(HttpRequest<S>) -> R + 'static,
|
where F: Fn(HttpRequest<S>) -> R + 'static,
|
||||||
R: Into<Reply> + 'static, {
|
R: Into<Reply> + 'static, {
|
||||||
self.routes.insert(Method::POST, Box::new(WrapHandler::new(handler)));
|
self.routes.insert(Method::POST, Box::new(WrapHandler::new(handler)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handler for `PUT` method.
|
/// Register handler for `PUT` method.
|
||||||
pub fn put<F, R>(&mut self, handler: F)
|
pub fn put<F, R>(&mut self, handler: F)
|
||||||
where F: Fn(HttpRequest<S>) -> R + 'static,
|
where F: Fn(HttpRequest<S>) -> R + 'static,
|
||||||
R: Into<Reply> + 'static, {
|
R: Into<Reply> + 'static, {
|
||||||
self.routes.insert(Method::PUT, Box::new(WrapHandler::new(handler)));
|
self.routes.insert(Method::PUT, Box::new(WrapHandler::new(handler)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handler for `DELETE` method.
|
/// Register handler for `DELETE` method.
|
||||||
pub fn delete<F, R>(&mut self, handler: F)
|
pub fn delete<F, R>(&mut self, handler: F)
|
||||||
where F: Fn(HttpRequest<S>) -> R + 'static,
|
where F: Fn(HttpRequest<S>) -> R + 'static,
|
||||||
R: Into<Reply> + 'static, {
|
R: Into<Reply> + 'static, {
|
||||||
|
Loading…
Reference in New Issue
Block a user