1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-26 02:19:22 +02:00

Application, router, resource builders

This commit is contained in:
Nikolay Kim
2017-10-15 14:17:41 -07:00
parent 5480cb5d49
commit 5901f0f9f5
11 changed files with 406 additions and 146 deletions

View File

@ -105,24 +105,24 @@ fn main() {
let sys = actix::System::new("http-example");
let mut routes = RoutingMap::default();
let mut app = Application::default();
app.add("/test")
.get::<MyRoute>()
.post::<MyRoute>();
routes.add("/blah", app);
routes.add_resource("/test")
.post::<MyRoute>();
routes.add_resource("/ws/")
.get::<MyWS>();
let http = HttpServer::new(routes);
http.serve::<()>(
&net::SocketAddr::from_str("127.0.0.1:9080").unwrap()).unwrap();
HttpServer::new(
RoutingMap::default()
.app(
"/blah", Application::default()
.resource("/test", |r| {
r.get::<MyRoute>();
r.post::<MyRoute>();
})
.finish())
.resource("/test", |r| r.post::<MyRoute>())
.resource("/ws/", |r| r.get::<MyWS>())
.resource("/simple/", |r|
r.handler(Method::GET, |req, payload, state| {
httpcodes::HTTPOk
}))
.finish())
.serve::<()>(
&net::SocketAddr::from_str("127.0.0.1:9080").unwrap()).unwrap();
println!("starting");
let _ = sys.run();