cors

package
v2.0.0-alpha.101 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetGlobalPolicy

func SetGlobalPolicy(h Handler)

Sets a global CORS policy that will be applied to incoming requests. The input parameter `h` is an implementation of the Handler interface used to add CORS headers to responses.

Types

type Handler

type Handler func(http.ResponseWriter, *http.Request)

func AllowAll

func AllowAll() Handler

Creates a CORS Handler that allows all origins by setting "Access-Control-Allow-Origin" header to "*". This means any domain can access resources on your server. It also specifies allowed methods and headers.

func GetGlobalPolicy

func GetGlobalPolicy() Handler

Retrieves the currently set global CORS policy handler.

func SameOrigin

func SameOrigin(origin ...string) Handler

Creates a CORS Handler that allows requests from the origin within the specified second-level domain scopes. For example:

SameOrigin("domain1.com", "domain2.com")

will allow requests from http://app1.domain1.com:8080 or https://app2.domain2.com.

Jump to

Keyboard shortcuts

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