cors

package module
v0.0.0-...-f15b73e Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: MIT Imports: 5 Imported by: 1

README

go-cors

Package cors provides tools for working with Cross-Origin Resource Sharing (CORS), for the Go programming language.

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-cors

GoDoc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProxyHandler

type ProxyHandler struct {
	LogWriter io.Writer
}

ProxyHandler is used to create a CORS proxy.

If ProxyHandler is being used on the Internet domain ‘example.com’, then a request to:

http://example.com/http://something.tld/blog/feed.atom

Would make a server-side request to:

http://something.tld/blog/feed.atom

And request the response with the addition of two headers:

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, DELETE, HEAD, OPTIONS, PATCH, POST, PUT, TRACE

Example usage:

var handler http.Handler = &cors.ProxyHandler{
	LogWriter: os.Stdout,
}

err := http.ListenAndServe(addr, handler)

func (*ProxyHandler) ServeHTTP

func (receiver *ProxyHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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