Session serialization will use gob encoding instead of json. Binary size will likely be reduced. General backend code refactoring.
16 lines
531 B
Go
16 lines
531 B
Go
package middlewares
|
|
|
|
import "net/http"
|
|
|
|
// Middleware for applying CORS policy for ALL hosts and for
|
|
// allowing ALL request headers.
|
|
func CORS(next http.Handler) http.Handler {
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Access-Control-Allow-Origin", "*")
|
|
w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
|
|
w.Header().Set("Access-Control-Allow-Headers", "*")
|
|
w.Header().Set("Access-Control-Allow-Credentials", "true")
|
|
next.ServeHTTP(w, r)
|
|
})
|
|
}
|