Skip to content

Commit

Permalink
remove Response::ok
Browse files Browse the repository at this point in the history
Signed-off-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
  • Loading branch information
yoshuawuyts committed Nov 19, 2019
1 parent b21b67f commit 5096627
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/response/into_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ pub trait IntoResponse: Send + Sized {

impl IntoResponse for String {
fn into_response(self) -> Response {
Response::ok()
Response::new(200)
.set_header("Content-Type", "text/plain; charset=utf-8")
.body_string(self)
}
}

impl<State: Send + Sync + 'static> IntoResponse for Request<State> {
fn into_response(self) -> Response {
Response::ok().body(self)
Response::new(200).body(self)
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn hello_world() -> Result<(), surf::Exception> {
let mut app = tide::new();
app.at("/").get(|mut req: tide::Request<()>| async move {
assert_eq!(req.body_string().await.unwrap(), "nori".to_string());
tide::Response::ok().body_string("says hello".to_string())
tide::Response::new(200).body_string("says hello".to_string())
});
app.listen("localhost:8080").await?;
Result::<(), surf::Exception>::Ok(())
Expand Down Expand Up @@ -67,7 +67,7 @@ fn json() -> Result<(), surf::Exception> {
let mut counter: Counter = req.body_json().await.unwrap();
assert_eq!(counter.count, 0);
counter.count = 1;
tide::Response::ok().body_json(&counter).unwrap()
tide::Response::new(200).body_json(&counter).unwrap()
});
app.listen("localhost:8082").await?;
Result::<(), surf::Exception>::Ok(())
Expand Down

0 comments on commit 5096627

Please sign in to comment.