Last active
October 31, 2019 03:50
-
-
Save JulioTalavera/e119fa36f50b69db764b8a0bf21d348d to your computer and use it in GitHub Desktop.
Go Lang Mux CORS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var router *mux.Router | |
router = mux.NewRouter().StrictSlash(true) | |
router.Use(mux.CORSMethodMiddleware(router)) | |
router.Headers("Access-Control-Allow-Origin", "*") | |
router.Headers("Content-Type", "application/json; charset=utf-8;") | |
router.Headers("X-Requested-With", "*") | |
router.Headers("Access-Control-Allow-Headers", "Origin,Content-Type,Accept") | |
router.HandleFunc("/", SomeRootRouteHandler).Methods(http.MethodGet, http.MethodOptions) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment