This commit is contained in:
genofire 2019-12-28 17:44:54 +01:00 committed by Timm
commit 89ae122fc3
9 changed files with 113 additions and 114 deletions

View file

@ -1,9 +1,9 @@
package main
import (
"net/http"
"github.com/gorilla/mux"
"log"
"net/http"
)
func NewRouter() *mux.Router {
@ -13,21 +13,21 @@ func NewRouter() *mux.Router {
handler = Logger(route.Handler, route.Name)
router.
Methods(route.Method).
Path(route.Pattern).
Name(route.Name).
Handler(handler)
Methods(route.Method).
Path(route.Pattern).
Name(route.Name).
Handler(handler)
router.
Methods("OPTIONS").
Name("Options Handler").
Handler(http.HandlerFunc(optionsHandler))
Methods("OPTIONS").
Name("Options Handler").
Handler(http.HandlerFunc(optionsHandler))
}
router.
Methods("OPTIONS").
Name("Options Handler").
Handler(http.HandlerFunc(optionsHandler))
Methods("OPTIONS").
Name("Options Handler").
Handler(http.HandlerFunc(optionsHandler))
router.NotFoundHandler = http.HandlerFunc(notFound)
@ -48,4 +48,4 @@ func optionsHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Headers", "Content-Type")
w.Header().Set("Access-Control-Allow-Methods", "POST, GET, PUT, DELETE")
w.WriteHeader(200)
}
}