MethodRouter
struct MethodRouter
An router handler for composing handlers based on the request method.
Implementions
Methods
[src]
pub fn handle(self, request: Request): Response throws {
if (let handler = self.handlers.get(request.method())) {
return try handler.handle(request);
} else {
return Response.text(http.NotFound.to_string()).set_status(http.NotFound);
}
}
[src]
pub fn handle(self, request: Request): Response throws {
if (let handler = self.handlers.get(request.method())) {
return try handler.handle(request);
} else {
return Response.text(http.NotFound.to_string()).set_status(http.NotFound);
}
}
options
pub fn options(self, handler: Handler): MethodRouter
[src]
pub fn options(self, handler: Handler): MethodRouter {
self.handlers.set(Method.Options, handler);
return self;
}
Adds a handler for the OPTIONS method.
options
pub fn options(self, handler: Handler): MethodRouter
[src]
pub fn options(self, handler: Handler): MethodRouter {
self.handlers.set(Method.Options, handler);
return self;
}
Adds a handler for the OPTIONS method.
Adds a handler for the OPTIONS method.
get
pub fn get(self, handler: Handler): MethodRouter
[src]
pub fn get(self, handler: Handler): MethodRouter {
self.handlers.set(Method.Get, handler);
return self;
}
Adds a handler for the GET method.
get
pub fn get(self, handler: Handler): MethodRouter
[src]
pub fn get(self, handler: Handler): MethodRouter {
self.handlers.set(Method.Get, handler);
return self;
}
Adds a handler for the GET method.
Adds a handler for the GET method.
post
pub fn post(self, handler: Handler): MethodRouter
[src]
pub fn post(self, handler: Handler): MethodRouter {
self.handlers.set(Method.Post, handler);
return self;
}
Adds a handler for the POST method.
post
pub fn post(self, handler: Handler): MethodRouter
[src]
pub fn post(self, handler: Handler): MethodRouter {
self.handlers.set(Method.Post, handler);
return self;
}
Adds a handler for the POST method.
Adds a handler for the POST method.
put
pub fn put(self, handler: Handler): MethodRouter
[src]
pub fn put(self, handler: Handler): MethodRouter {
self.handlers.set(Method.Put, handler);
return self;
}
Adds a handler for the PUT method.
put
pub fn put(self, handler: Handler): MethodRouter
[src]
pub fn put(self, handler: Handler): MethodRouter {
self.handlers.set(Method.Put, handler);
return self;
}
Adds a handler for the PUT method.
Adds a handler for the PUT method.
delete
pub fn delete(self, handler: Handler): MethodRouter
[src]
pub fn delete(self, handler: Handler): MethodRouter {
self.handlers.set(Method.Delete, handler);
return self;
}
Adds a handler for the DELETE method.
delete
pub fn delete(self, handler: Handler): MethodRouter
[src]
pub fn delete(self, handler: Handler): MethodRouter {
self.handlers.set(Method.Delete, handler);
return self;
}
Adds a handler for the DELETE method.
Adds a handler for the DELETE method.
head
pub fn head(self, handler: Handler): MethodRouter
[src]
pub fn head(self, handler: Handler): MethodRouter {
self.handlers.set(Method.Head, handler);
return self;
}
Adds a handler for the HEAD method.
head
pub fn head(self, handler: Handler): MethodRouter
[src]
pub fn head(self, handler: Handler): MethodRouter {
self.handlers.set(Method.Head, handler);
return self;
}
Adds a handler for the HEAD method.
Adds a handler for the HEAD method.
trace
pub fn trace(self, handler: Handler): MethodRouter
[src]
pub fn trace(self, handler: Handler): MethodRouter {
self.handlers.set(Method.Trace, handler);
return self;
}
Adds a handler for the TRACE method.
trace
pub fn trace(self, handler: Handler): MethodRouter
[src]
pub fn trace(self, handler: Handler): MethodRouter {
self.handlers.set(Method.Trace, handler);
return self;
}
Adds a handler for the TRACE method.
Adds a handler for the TRACE method.
patch
pub fn patch(self, handler: Handler): MethodRouter
[src]
pub fn patch(self, handler: Handler): MethodRouter {
self.handlers.set(Method.Patch, handler);
return self;
}
Adds a handler for the PATCH method.
patch
pub fn patch(self, handler: Handler): MethodRouter
[src]
pub fn patch(self, handler: Handler): MethodRouter {
self.handlers.set(Method.Patch, handler);
return self;
}
Adds a handler for the PATCH method.
Adds a handler for the PATCH method.