Struct gotham_restful::Response
source · pub struct Response { /* private fields */ }
Expand description
A response, used to create the final gotham response from.
This type is not meant to be used as the return type of endpoint handlers. While it can be
freely used without the openapi
feature, it is more complicated to use when you enable it,
since this type does not store any schema information. You can attach schema information
like so:
fn schema(code: StatusCode) -> OpenapiSchema {
assert_eq!(code, StatusCode::ACCEPTED);
<()>::schema()
}
fn status_codes() -> Vec<StatusCode> {
vec![StatusCode::ACCEPTED]
}
#[create(schema = "schema", status_codes = "status_codes")]
fn create(body: Raw<Vec<u8>>) {}
Implementations§
source§impl Response
impl Response
sourcepub fn new<B: Into<Body>>(
status: StatusCode,
body: B,
mime: Option<Mime>
) -> Self
pub fn new<B: Into<Body>>( status: StatusCode, body: B, mime: Option<Mime> ) -> Self
Create a new Response from raw data.
sourcepub fn json<B: Into<Body>>(status: StatusCode, body: B) -> Self
pub fn json<B: Into<Body>>(status: StatusCode, body: B) -> Self
Create a Response with mime type json from already serialized data.
sourcepub fn no_content() -> Self
pub fn no_content() -> Self
Create a 204 No Content Response.
sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Return the status code of this Response.
sourcepub fn header(&mut self, name: HeaderName, value: HeaderValue)
pub fn header(&mut self, name: HeaderName, value: HeaderValue)
Add an HTTP header to the Response.
Trait Implementations§
Auto Trait Implementations§
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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoSql for T
impl<T> IntoSql for T
source§fn into_sql<T>(self) -> Self::Expressionwhere
Self: AsExpression<T> + Sized,
T: SqlType + TypedExpressionType,
fn into_sql<T>(self) -> Self::Expressionwhere Self: AsExpression<T> + Sized, T: SqlType + TypedExpressionType,
Convert
self
to an expression for Diesel’s query builder. Read moresource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere
&'a Self: AsExpression<T>,
T: SqlType + TypedExpressionType,
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,
Convert
&self
to an expression for Diesel’s query builder. Read more