pub struct Response { /* private fields */ }Expand description
An HTTP response.
use giong_http::Response;
let ok = Response::json(r#"{"ok":true}"#);
let missing = Response::new(404).header("Cache-Control", "no-store").body("not found");Implementations§
Source§impl Response
impl Response
Sourcepub fn new(status: u16) -> Self
pub fn new(status: u16) -> Self
A response with the given status code and no body.
§Panics
Panics if status is not in 200..=599. Interim (1xx) responses are
sent by the server itself.
Sourcepub fn header(self, name: &str, value: &str) -> Self
pub fn header(self, name: &str, value: &str) -> Self
Adds a header field.
Content-Length, Transfer-Encoding, Connection and Date are
managed by the server; setting them here is ignored.
§Panics
Panics if name is not a valid header name or value contains control
characters. Building headers from untrusted input without checking it
would otherwise allow response splitting.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Response
impl Freeze for Response
impl Move for Response
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnsafeUnpin for Response
impl UnwindSafe for Response
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more