Back to / pkg / cors

Package cors

Latest Go to latest

The latest major version is .

Published: May 20, 2020 | License: Apache-2.0 | Module:


Package cors handles cross-origin HTTP requests (CORS).


type CORSHandler

type CORSHandler struct {
	Handler http.Handler
	Info    *CORSInfo

func (*CORSHandler) ServeHTTP

func (h *CORSHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP adds the correct CORS headers based on the origin and returns immediately with a 200 OK if the method is OPTIONS.

type CORSInfo

type CORSInfo map[string]bool

func (CORSInfo) OriginAllowed

func (c CORSInfo) OriginAllowed(origin string) bool

OriginAllowed determines whether the server will allow a given CORS origin.

func (*CORSInfo) Set

func (ci *CORSInfo) Set(s string) error

Set implements the flag.Value interface to allow users to define a list of CORS origins

func (*CORSInfo) String

func (ci *CORSInfo) String() string

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier