22 lines
505 B
Go
22 lines
505 B
Go
package openapi
|
|
|
|
import "net/http"
|
|
|
|
type ServeMux struct {
|
|
*http.ServeMux
|
|
}
|
|
|
|
func NewServeMux() *ServeMux {
|
|
return &ServeMux{http.NewServeMux()}
|
|
}
|
|
|
|
func (c *ServeMux) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Access-Control-Allow-Origin", "*")
|
|
w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE")
|
|
w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization")
|
|
if r.Method == http.MethodOptions {
|
|
return
|
|
}
|
|
c.ServeMux.ServeHTTP(w, r)
|
|
}
|