mirror of
https://github.com/actix/actix-extras.git
synced 2025-06-25 09:59:21 +02:00
refactory response body
This commit is contained in:
@ -17,8 +17,8 @@ fn with_param(req: &mut HttpRequest, _payload: Payload, state: &()) -> HttpRespo
|
||||
|
||||
HttpResponse::builder(StatusCode::OK)
|
||||
.content_type("test/plain")
|
||||
.body(Body::Binary(
|
||||
format!("Hello {}!", req.match_info().get("name").unwrap()).into())).unwrap()
|
||||
.body(format!("Hello {}!", req.match_info().get("name").unwrap()))
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -19,7 +19,7 @@ fn index(req: &mut HttpRequest, _: Payload, state: &AppState) -> HttpResponse {
|
||||
println!("{:?}", req);
|
||||
state.counter.set(state.counter.get() + 1);
|
||||
httpcodes::HTTPOk.with_body(
|
||||
Body::Binary(format!("Num of requests: {}", state.counter.get()).into()))
|
||||
format!("Num of requests: {}", state.counter.get()))
|
||||
}
|
||||
|
||||
/// `MyWebSocket` counts how many messages it receives from peer,
|
||||
|
Reference in New Issue
Block a user