|
@@ -106,10 +106,11 @@ func WithCors(origin ...string) RunOption {
|
|
|
|
|
|
// WithCustomCors returns a func to enable CORS for given origin, or default to all origins (*),
|
|
|
// fn lets caller customizing the response.
|
|
|
-func WithCustomCors(fn func(http.ResponseWriter), origin ...string) RunOption {
|
|
|
+func WithCustomCors(middlewareFn func(header http.Header), notAllowedFn func(http.ResponseWriter),
|
|
|
+ origin ...string) RunOption {
|
|
|
return func(server *Server) {
|
|
|
- server.router.SetNotAllowedHandler(cors.NotAllowedHandler(fn, origin...))
|
|
|
- server.Use(cors.Middleware(fn, origin...))
|
|
|
+ server.router.SetNotAllowedHandler(cors.NotAllowedHandler(notAllowedFn, origin...))
|
|
|
+ server.Use(cors.Middleware(middlewareFn, origin...))
|
|
|
}
|
|
|
}
|
|
|
|