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
sourceimpl 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
sourceimpl IntoResponse for Response
impl IntoResponse for Response
type Err = Infallible
sourcefn into_response(self) -> BoxFuture<'static, Result<Response, Self::Err>>
fn into_response(self) -> BoxFuture<'static, Result<Response, Self::Err>>
Turn this into a response that can be returned to the browser. This api will likely
change in the future. Read more
sourcefn accepted_types() -> Option<Vec<Mime>>
fn accepted_types() -> Option<Vec<Mime>>
Return a list of supported mime types.
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoSql for T
impl<T> IntoSql for T
sourcefn into_sql<T>(self) -> Self::Expressionwhere
Self: AsExpression<T>,
T: SqlType + TypedExpressionType,
fn into_sql<T>(self) -> Self::Expressionwhere
Self: AsExpression<T>,
T: SqlType + TypedExpressionType,
Convert
self
to an expression for Diesel’s query builder. Read moresourcefn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere
T: SqlType + TypedExpressionType,
&'a Self: AsExpression<T>,
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere
T: SqlType + TypedExpressionType,
&'a Self: AsExpression<T>,
Convert
&self
to an expression for Diesel’s query builder. Read more