Trait poem_openapi::ApiResponse

source ·
pub trait ApiResponse: Sized {
    const BAD_REQUEST_HANDLER: bool = false;

    // Required methods
    fn meta() -> MetaResponses;
    fn register(registry: &mut Registry);

    // Provided method
    fn from_parse_request_error(err: Error) -> Self { ... }
}
Expand description

Represents a OpenAPI responses object.

§Provided Implementations

  • Binary<T: Type>

    A binary response with content type application/octet-stream.

  • Json<T: Type>

    A JSON response with content type application/json.

  • PlainText<T: Type>

    A utf8 string response with content type text/plain.

  • Attachment<T: Type>

    A file download response, the content type is application/octet-stream.

  • Response<T: Type>

    A response type use it to modify the status code and HTTP headers.

  • ()

    It means that this API does not have any response body.

  • poem::Result<T: ApiResponse>

    It means that an error may occur in this API.

  • Any type derived from the ApiResponse macro

    A complex response derived from the ApiResponse macro.

Provided Associated Constants§

source

const BAD_REQUEST_HANDLER: bool = false

If true, it means that the response object has a custom bad request handler.

Required Methods§

source

fn meta() -> MetaResponses

Gets metadata of this response.

source

fn register(registry: &mut Registry)

Register the schema contained in this response object to the registry.

Provided Methods§

source

fn from_parse_request_error(err: Error) -> Self

Convert poem::Error to this response object.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl ApiResponse for StaticFileResponse

source§

fn meta() -> MetaResponses

source§

fn register(_registry: &mut Registry)

source§

impl ApiResponse for ()

source§

fn meta() -> MetaResponses

source§

fn register(_registry: &mut Registry)

source§

impl ApiResponse for Error

source§

fn meta() -> MetaResponses

source§

fn register(_registry: &mut Registry)

source§

impl<F, Fut> ApiResponse for WebSocketUpgraded<F>
where F: FnOnce(WebSocketStream) -> Fut + Send + Sync + 'static, Fut: Future + Send + 'static,

source§

fn meta() -> MetaResponses

source§

fn register(_registry: &mut Registry)

source§

impl<T, E> ApiResponse for Result<T, E>
where T: ApiResponse, E: ApiResponse + Into<Error> + Send + Sync + 'static,

source§

const BAD_REQUEST_HANDLER: bool = T::BAD_REQUEST_HANDLER

source§

fn meta() -> MetaResponses

source§

fn register(registry: &mut Registry)

source§

fn from_parse_request_error(err: Error) -> Self

Implementors§

source§

impl<T: AsRef<[u8]> + Send> ApiResponse for Base64<T>

source§

impl<T: Into<String> + Send> ApiResponse for Html<T>

source§

impl<T: Into<String> + Send> ApiResponse for PlainText<T>

source§

impl<T: Into<Body> + Send> ApiResponse for Attachment<T>

source§

impl<T: Into<Body> + Send> ApiResponse for Binary<T>

source§

impl<T: Stream<Item = E> + Send + 'static, E: Type + ToJSON> ApiResponse for EventStream<T>

source§

impl<T: ApiResponse> ApiResponse for Response<T>

source§

const BAD_REQUEST_HANDLER: bool = T::BAD_REQUEST_HANDLER

source§

impl<T: ToJSON> ApiResponse for Json<T>

source§

impl<T: ToXML> ApiResponse for Xml<T>

source§

impl<T: ToYAML> ApiResponse for Yaml<T>