cors

package
v0.0.0-...-0f66f00 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2020 License: BSD-2-Clause Imports: 3 Imported by: 8

Documentation

Overview

Package cors contains filters to handle CORS related requests defined from http://www.w3.org/TR/cors/

Index

Constants

View Source
const DefaultAllowOrigin = "*"

DefaultAllowOrigin sets Access-Control-Allow-Origin when not configured.

Variables

This section is empty.

Functions

func Get

func Get(origin string, next http.Handler) http.Handler

Get implements a simple read-only access control policy handling preflight and normal requests with a cache age of 10 minutes for preflight requests. Methods other than HEAD, OPTIONS, GET will return 405.

The origin parameter should be the case-insentive fully qualified origin domain to match or '*' to match any domain.

func Middleware

func Middleware(cfg Config) func(http.Handler) http.Handler

Middleware returns a middleware that applies Config to the request.

Types

type Config

type Config struct {
	// AllowOrigin transforms a request into the Access-Control-Allow-Origin
	// header, default is full access "*".
	AllowOrigin func(*http.Request) string
}

Config parameterizes CORS behavior.

Jump to

Keyboard shortcuts

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