cors

package module
v0.0.0-...-dba2c48 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2023 License: MIT Imports: 4 Imported by: 0

README

CORS

License

Installation

go get github.com/gowool/middleware/cors

License

Distributed under MIT License, please see license file within the code for more details.

Documentation

Index

Constants

This section is empty.

Variables

Functions

func Middleware

func Middleware(cfg *Config) wool.Middleware

Types

type CORS

type CORS struct {
	// contains filtered or unexported fields
}

func New

func New(cfg *Config) *CORS

func (*CORS) Middleware

func (m *CORS) Middleware(next wool.Handler) wool.Handler

type Config

type Config struct {
	// AllowedOrigin: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin
	AllowedOrigin string `mapstructure:"allowed_origin"`

	// AllowedHeaders: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers
	AllowedHeaders string `mapstructure:"allowed_headers"`

	// AllowedMethods: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods
	AllowedMethods string `mapstructure:"allowed_methods"`

	// AllowCredentials https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials
	AllowCredentials *bool `mapstructure:"allow_credentials"`

	// ExposeHeaders:  https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Expose-Headers
	ExposedHeaders string `mapstructure:"exposed_headers"`

	// MaxAge of CORS headers in seconds/
	MaxAge int `mapstructure:"max_age"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL