by mercurial · 12y ago · 0 comments
fn (context: Context, req: FromRequest) -> ToResponse
trait FromRequest {
fn from_request<'a>(req: &'a Request) -> &'a Self;
}
impl FromRequest for Request {
fn from_request<'a>(req: &'a Request) -> &'a Request {
req
}
}
This would remove a lot of boilerplate for well-behaved applications. You'll also need a notion of middleware, which I guess would take a Request and return either a ToResponse or a request (eg, an authentication handler ought to return the response immediately in case of authentication failure), and similarly on the way out, something taking a Response and returning a Response.