Skip to content

jub0bs/cors-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cors-examples

What is this?

This repository is a collection of examples that illustrate how to use github.com/jub0bs/cors, a principled CORS middleware library, in conjunction with net/http and popular third-party routers for Go.

What is the example?

The example invariably consists in creating a CORS middleware that

  • allows anonymous access from Web origin https://example.com,
  • with requests whose method is either GET or POST, and
  • (optionally) with request header Authorization,

and applying the middleware in question to all the resources accessible under an /api/ path.

In addition, a /hello path is left unconfigured for CORS.

Which routers are represented?

Library Compatibility Path to example
Chi v5.0+ chi=v5/main.go
Echo v4.11+ echo-v4/main.go
Fiber v2.52+ fiber-v2/main.go
gorilla/mux v1.8+ gorilla-mux/main.go
net/http v1.22+ net-http/main.go

About

A collection of examples showing how to use jub0bs/cors with various routers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages