cors

package
v1.0.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2020 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	Handler http.Handler
	Info    *Info
}

Handler wraps an http.Handler instance to provide configurable CORS support. CORS headers will be added to all responses.

func (*Handler) ServeHTTP

func (h *Handler) 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 Info

type Info map[string]bool

Info represents a set of allowed origins.

func (Info) OriginAllowed

func (ci Info) OriginAllowed(origin string) bool

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

func (*Info) Set

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

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

func (*Info) String

func (ci *Info) String() string

Jump to

Keyboard shortcuts

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