mirror of
https://github.com/notherealmarco/WASAPhoto.git
synced 2025-03-14 14:16:15 +01:00
20 lines
642 B
Go
20 lines
642 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"github.com/gorilla/handlers"
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
// applyCORSHandler applies a CORS policy to the router. CORS stands for Cross-Origin Resource Sharing: it's a security
|
||
|
// feature present in web browsers that blocks JavaScript requests going across different domains if not specified in a
|
||
|
// policy. This function sends the policy of this API server.
|
||
|
func applyCORSHandler(h http.Handler) http.Handler {
|
||
|
return handlers.CORS(
|
||
|
handlers.AllowedHeaders([]string{
|
||
|
"x-example-header",
|
||
|
}),
|
||
|
handlers.AllowedMethods([]string{"GET", "POST", "OPTIONS", "DELETE", "PUT"}),
|
||
|
handlers.AllowedOrigins([]string{"*"}),
|
||
|
)(h)
|
||
|
}
|