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

refactor response generation

This commit is contained in:
Nikolay Kim
2017-10-10 16:03:32 -07:00
parent 78e6149d9f
commit 0e6a67fc26
12 changed files with 239 additions and 127 deletions

View File

@ -24,7 +24,7 @@ impl Route for MyRoute {
ctx.add_stream(payload);
Reply::stream(MyRoute{req: Some(req)})
} else {
Reply::with(req, httpcodes::HTTPOk)
Reply::reply(req, httpcodes::HTTPOk)
}
}
}
@ -42,7 +42,7 @@ impl Handler<PayloadItem> for MyRoute {
{
println!("CHUNK: {:?}", msg);
if let Some(req) = self.req.take() {
ctx.start(httpcodes::HTTPOk.response(req));
ctx.start(req, httpcodes::HTTPOk);
ctx.write_eof();
}
Self::empty()
@ -59,14 +59,14 @@ impl Route for MyWS {
type State = ();
fn request(req: HttpRequest, payload: Payload, ctx: &mut HttpContext<Self>) -> Reply<Self> {
match ws::handshake(req) {
match ws::handshake(&req) {
Ok(resp) => {
ctx.start(resp);
ctx.start(req, resp);
ctx.add_stream(ws::WsStream::new(payload));
Reply::stream(MyWS{})
},
Err(err) =>
Reply::reply(err)
Reply::reply(req, err)
}
}
}