pub struct Response {
pub status_code: String,
pub body: Vec<u8>,
pub cookie: ResponseCookies,
pub setting: ResponseHeaders,
}
Expand description
Response.
Fields§
§status_code: String
HTTP status code.
body: Vec<u8>
Response body.
Response Cookies.
setting: ResponseHeaders
Response Headers.
Implementations§
Source§impl Response
impl Response
HTML file builder.
Sourcepub fn html<Q: FnOnce(&mut Response), W: FnOnce(&mut Response)>(
&mut self,
head: Q,
body: W,
)
pub fn html<Q: FnOnce(&mut Response), W: FnOnce(&mut Response)>( &mut self, head: Q, body: W, )
Function to run Response::echo.
- head = Function to create HEAD HTML.
- body = Function to create BODY HTML.
§Examples
let mut response = RESPONSE_DEF.clone();
response.html(
|resp| resp.echo("Example Head"),
|resp| resp.echo("Example Body");,
);
Sourcepub fn echo<Q: AsRef<[u8]>>(&mut self, data: Q)
pub fn echo<Q: AsRef<[u8]>>(&mut self, data: Q)
Adding a line to html. If you use outside Response::html, run self.set_response(“200 OK”, “”); before using.
- data = Line to add.
§Examples
let mut response = RESPONSE_DEF.clone();
response.html(
|resp| resp.echo("Example Head"),
|resp| resp.echo("Example Body");,
);
Source§impl Response
impl Response
Functions to change Response.
Sourcepub fn set_response<Q, W: AsRef<[u8]>>(&mut self, status: Q, string_data: W)
pub fn set_response<Q, W: AsRef<[u8]>>(&mut self, status: Q, string_data: W)
Inserts HTTP code status and data into Response.
- status = HTTP code status.
- data = Recorded data.
§Examples
let mut response = RESPONSE_DEF.clone();
response.set_response("200 OK", "All good");
Sourcepub fn set_redirect<Q: AsRef<[u8]>>(&mut self, location: Q)
pub fn set_redirect<Q: AsRef<[u8]>>(&mut self, location: Q)
Redirecting the client to a specific url.
- location = Redirect url.
§Examples
let mut response = RESPONSE_DEF.clone();
response.set_redirect("/test_url");
Trait Implementations§
Source§impl Ord for Response
impl Ord for Response
Source§impl PartialOrd for Response
impl PartialOrd for Response
impl Eq for Response
impl StructuralPartialEq for Response
Auto Trait Implementations§
impl Freeze for Response
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin 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