mirror of
https://github.com/actix/actix-web.git
synced 2024-11-25 19:11:10 +00:00
export Handler
This commit is contained in:
parent
16ceb741b8
commit
427566b90d
4 changed files with 7 additions and 8 deletions
|
@ -72,7 +72,6 @@ extern crate env_logger;
|
|||
use actix::*;
|
||||
use actix_web::*;
|
||||
|
||||
|
||||
struct MyWebSocket;
|
||||
|
||||
/// Actor with http context
|
||||
|
@ -112,7 +111,8 @@ fn main() {
|
|||
.middleware(middlewares::Logger::default())
|
||||
// websocket route
|
||||
.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();
|
||||
|
||||
Arbiter::system().send(msgs::SystemExit(0));
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
// dev specific
|
||||
pub use task::Task;
|
||||
pub use route::Handler;
|
||||
pub use pipeline::Pipeline;
|
||||
pub use recognizer::RouteRecognizer;
|
||||
pub use channel::HttpChannel;
|
||||
|
|
|
@ -82,7 +82,7 @@ pub use application::Application;
|
|||
pub use httprequest::{HttpRequest, UrlEncoded};
|
||||
pub use httpresponse::HttpResponse;
|
||||
pub use payload::{Payload, PayloadItem};
|
||||
pub use route::{Frame, Reply};
|
||||
pub use route::{Frame, Reply, Handler};
|
||||
pub use resource::Resource;
|
||||
pub use recognizer::Params;
|
||||
pub use server::HttpServer;
|
||||
|
|
|
@ -80,28 +80,28 @@ impl<S> Resource<S> where S: 'static {
|
|||
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)
|
||||
where F: Fn(HttpRequest<S>) -> R + 'static,
|
||||
R: Into<Reply> + 'static, {
|
||||
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)
|
||||
where F: Fn(HttpRequest<S>) -> R + 'static,
|
||||
R: Into<Reply> + 'static, {
|
||||
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)
|
||||
where F: Fn(HttpRequest<S>) -> R + 'static,
|
||||
R: Into<Reply> + 'static, {
|
||||
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)
|
||||
where F: Fn(HttpRequest<S>) -> R + 'static,
|
||||
R: Into<Reply> + 'static, {
|
||||
|
|
Loading…
Reference in a new issue