logo
pub struct Cors { /* private fields */ }
Expand description

Middleware for CORS

Errors

Example

use poem::{http::Method, middleware::Cors};

let cors = Cors::new()
    .allow_method(Method::GET)
    .allow_method(Method::POST)
    .allow_credentials(false);

Implementations

Creates a new CORS middleware.

Set allow credentials.

Add an allow header.

NOTE: Default is allow any header.

Add many allow headers.

Add an allow method.

NOTE: Default is allow any method.

Add many allow methods.

Add an allow origin.

NOTE: Default is allow any origin.

Add many allow origins.

Determinate allowed origins by processing requests which didn’t match any origins specified in the allow_origin.

This function will receive the Origin header, which can be used to determine whether to allow the request.

Add an expose header.

Add many expose headers.

Set max age.

Trait Implementations

Returns the “default value” for a type. Read more

New endpoint type. Read more

Transform the input Endpoint to another one.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Attaches the provided Context to this type, returning a WithContext wrapper. Read more

Attaches the current Context to this type, returning a WithContext wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more