3
0
corteza/pkg/api/cors.go
Denis Arh 5a9bce44e8 Cleanup internal, vendors, cleanup cmd/*
Introduces /pkg for non-intenral packages
2019-05-24 12:44:56 +02:00

19 lines
529 B
Go

package api
import (
"net/http"
"github.com/go-chi/cors"
)
// Sets up default CORS rules to use as a middleware
func handleCORS(next http.Handler) http.Handler {
return cors.New(cors.Options{
AllowedOrigins: []string{"*"},
AllowedMethods: []string{"GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"},
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token"},
AllowCredentials: true,
MaxAge: 300, // Maximum value not ignored by any of major browsers
}).Handler(next)
}