-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
Hi fellow go-chi authors,
I was looking into why we created this fork in the first place.
Note: The upstream repo has a go-chi example at https://github.com/rs/cors/blob/master/examples/chi/server.go.
1. We have introduced this API breaking change:
type Cors struct {
// Optional origin validator function
- allowOriginFunc func(origin string) bool
+ allowOriginFunc func(r *http.Request, origin string) bool
}
=> It looks like upstream adopted this change via rs/cors#59
type Cors struct {
// Optional origin validator function
allowOriginFunc func(origin string) bool
+ // Optional origin validator (with request) function
+ allowOriginRequestFunc func(r *http.Request, origin string) bool
}
2. We have introduced cors.Handler()
function
+ // Handler creates a new Cors handler with passed options.
+ func Handler(options Options) func(next http.Handler) http.Handler
which returns middleware via cors.New(opts).Handler
behind the scenes
3. We have removed few functions:
- // Default creates a new Cors handler with default options.
- func Default() *Cors
- // check the Origin of a request. No origin at all is also allowed.
- func (c *Cors) OriginAllowed(r *http.Request) bool
- // HandlerFunc provides Martini compatible handler
- func (c *Cors) HandlerFunc(w http.ResponseWriter, r *http.Request)
- // Negroni compatible interface
- func (c *Cors) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
4. Is there anything else I'm missing?
I wonder if you'd be OK with documenting these changes in the main README.
Metadata
Metadata
Assignees
Labels
No labels