cors

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2018 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package cors provides CORS support for http.Handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

Handler is an http.Handler that wraps other http.Handlers and provides CORS support.

func NewHandler

func NewHandler(h http.Handler) *Handler

NewHandler wraps an existing http.Handler allowing it to be requested via CORS.

func (*Handler) AllowCredentials

func (h *Handler) AllowCredentials(allow bool)

AllowCredentials allows cookies to be read by the CORS request.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP determines if a request is a CORS request (normal or preflight) and sets the appropriate Access-Control-Allow-* headers. It will send the request to the underlying handler in all cases, except for a preflight (OPTIONS) request.

func (*Handler) SetOrigin

func (h *Handler) SetOrigin(origin string)

SetOrigin sets the origin(s) to allow when requested with CORS.

Jump to

Keyboard shortcuts

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