cors

package module
v0.0.0-...-98d9de6 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2014 License: Apache-2.0 Imports: 3 Imported by: 3

README

cors

CORS middleware for Go

  corsHandler := cors.New(myHandler)
  corsHandler.RemoveMethod("PUT")
  corsHandler.RemoveMethod("DELETE")
  max_age := 60 * time.Second
  corsHandler.SetMaxAge(max_age.Seconds())

  http.Handle("/", corsHandler)

  http.ListenAndServe("localhost:9999", nil)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CorsHandler

type CorsHandler struct {
	ALLOWED_METHODS   []string
	ALLOWED_ORIGINS   []string
	ALLOWED_HEADERS   []string
	EXPOSED_HEADERS   []string
	ALLOW_CREDENTIALS string
	MAX_AGE           float64
	// contains filtered or unexported fields
}

func New

func New(handler http.Handler) *CorsHandler

func (*CorsHandler) AllowCredentials

func (cors *CorsHandler) AllowCredentials(creds bool)

func (*CorsHandler) AllowHeader

func (cors *CorsHandler) AllowHeader(header string)

func (*CorsHandler) AllowMethod

func (cors *CorsHandler) AllowMethod(method string)

func (*CorsHandler) AllowOrigin

func (cors *CorsHandler) AllowOrigin(origin string)

func (*CorsHandler) AllowedHeaders

func (cors *CorsHandler) AllowedHeaders() string

func (*CorsHandler) AllowedMethods

func (cors *CorsHandler) AllowedMethods() string

func (*CorsHandler) ExposeHeader

func (cors *CorsHandler) ExposeHeader(header string)

func (*CorsHandler) ExposedHeaders

func (cors *CorsHandler) ExposedHeaders() string

func (*CorsHandler) IsHeaderAllowed

func (cors *CorsHandler) IsHeaderAllowed(header string) bool

func (*CorsHandler) IsMethodAllowed

func (cors *CorsHandler) IsMethodAllowed(method string) bool

func (*CorsHandler) IsOriginAllowed

func (cors *CorsHandler) IsOriginAllowed(origin string) bool

func (*CorsHandler) RemoveExposedHeader

func (cors *CorsHandler) RemoveExposedHeader(header string)

func (*CorsHandler) RemoveHeader

func (cors *CorsHandler) RemoveHeader(header string)

func (*CorsHandler) RemoveMethod

func (cors *CorsHandler) RemoveMethod(method string)

func (*CorsHandler) RemoveOrigin

func (cors *CorsHandler) RemoveOrigin(origin string)

func (*CorsHandler) ServeHTTP

func (cors *CorsHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*CorsHandler) SetMaxAge

func (cors *CorsHandler) SetMaxAge(age float64)

Jump to

Keyboard shortcuts

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