cors

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 5 Imported by: 5 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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