messua/layer/cors

Types

Object for configuring a CORS layer.

pub opaque type Config

Values

pub fn all_origins(cfg: Config) -> Config
pub fn allow_all_headers(cfg: Config) -> Config
pub fn allow_credentials(cfg: Config) -> Config
pub fn allow_header(cfg: Config, header: String) -> Config
pub fn allow_method(cfg: Config, method: http.Method) -> Config
pub fn allow_origin(cfg: Config, origin: String) -> Config
pub fn expose_all_headers(cfg: Config) -> Config
pub fn expose_header(cfg: Config, header: String) -> Config
pub fn make_layer(
  cfg: Config,
) -> fn(
  minc.Incoming(state),
  fn(minc.Incoming(state)) -> Result(
    response.Response(mist.ResponseData),
    fail.Failure,
  ),
) -> Result(response.Response(mist.ResponseData), fail.Failure)

Make a CORS Layer with the given configuration.

pub fn max_age(cfg: Config, seconds: Int) -> Config
pub fn new() -> Config

Create a new, maximally-restrictive CORS configuration:

  • allows methods GET, POST, & HEAD
  • no allowed origins
  • no allowed headers
  • no exposed headers
  • credentials not allowed
  • no statement about caching

These restrictions can be relaxed with the builder-pattern functions in this module.

Search Document