diff --git a/examples/database.rs b/examples/database.rs index 29c129aad..596e68a87 100644 --- a/examples/database.rs +++ b/examples/database.rs @@ -177,10 +177,11 @@ fn note_routes(request: &Request, db: &Transaction) -> Response { let id = id.unwrap(); - let mut response = Response::text("The note has been created"); - response.status_code = 201; - response.headers.push(("Location".to_owned(), format!("/note/{}", id))); - response + Response { + status_code: 201, + location: Some(format!("/note/{}", id).into()), + .. Response::text("The note has been created") + } }, (DELETE) (/note/{id: i32}) => { diff --git a/examples/websocket.rs b/examples/websocket.rs index a593b0df8..55a329f78 100644 --- a/examples/websocket.rs +++ b/examples/websocket.rs @@ -44,7 +44,7 @@ fn main() {
Received:
- ") + ").into() }, (GET) (/ws) => { @@ -73,7 +73,7 @@ fn main() { }, // Default 404 route as with all examples. - _ => rouille::Response::empty_404() + _ => rouille::Response::empty_404().into() ) }); } diff --git a/src/assets.rs b/src/assets.rs index aa6f74d86..14f3c6692 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -15,6 +15,7 @@ use time; use Request; use Response; +use ResponseCacheControl; use ResponseBody; /// Searches inside `path` for a file that matches the given request. If a file is found, @@ -128,24 +129,24 @@ pub fn match_assetsAn internal error has occurred on the server.
") .with_status_code(500) + .into() } } }; @@ -278,7 +281,7 @@ pub fn start_server(addr: A, handler: F) -> ! .with_data(res_data, res_len); for (key, value) in rouille_response.headers { - if let Ok(header) = tiny_http::Header::from_bytes(key, value) { + if let Ok(header) = tiny_http::Header::from_bytes(&*key, &*value) { response.add_header(header); } else { // TODO: ? @@ -430,7 +433,7 @@ impl Request { /// /// fn handle(request: &Request) -> Response { /// if !request.is_secure() { - /// return Response::redirect(&format!("https://example.com")); + /// return Response::redirect(format!("https://example.com")); /// } /// /// // ... diff --git a/src/log.rs b/src/log.rs index 4cb7b7c73..010c55ddc 100644 --- a/src/log.rs +++ b/src/log.rs @@ -15,7 +15,7 @@ use std::time::Instant; use chrono; use Request; -use Response; +use RawResponse; /// Adds a log entry to the given writer at each request. /// @@ -26,17 +26,18 @@ use Response; /// /// ``` /// use std::io; -/// use rouille::{Request, Response}; +/// use rouille::{Request, Response, RawResponse}; /// -/// fn handle(request: &Request) -> Response { +/// fn handle(request: &Request) -> RawResponse { /// rouille::log(request, io::stdout(), || { /// Response::text("hello world") /// }) /// } /// ``` -pub fn log