Added CORS-Header in Go #8

Merged
Alpha merged 3 commits from 123niel/tsviewer:master into master 2019-02-07 14:02:28 +00:00
Showing only changes of commit 53b246a6df - Show all commits

View file

@ -16,16 +16,23 @@ import (
"git.cliffbreak.de/Cliffbreak/tsviewer/service"
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
"github.com/go-chi/cors"
)
func Routes(s service.Service, t template.Template) *chi.Mux {
router := chi.NewRouter()
cors := cors.New(cors.Options{
AllowedOrigins: []string{"*"},
AllowedMethods: []string{"Get"},
})
router.Use(
middleware.Logger,
middleware.Timeout(5*time.Second),
middleware.DefaultCompress,
middleware.RedirectSlashes,
middleware.Recoverer,
cors.Handler,
)
router.Route("/v1", func(r chi.Router) {