added Cors-Header
This commit is contained in:
parent
1f523a6b7d
commit
53b246a6df
1 changed files with 7 additions and 0 deletions
7
main.go
7
main.go
|
@ -16,16 +16,23 @@ import (
|
||||||
"git.cliffbreak.de/Cliffbreak/tsviewer/service"
|
"git.cliffbreak.de/Cliffbreak/tsviewer/service"
|
||||||
"github.com/go-chi/chi"
|
"github.com/go-chi/chi"
|
||||||
"github.com/go-chi/chi/middleware"
|
"github.com/go-chi/chi/middleware"
|
||||||
|
"github.com/go-chi/cors"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Routes(s service.Service, t template.Template) *chi.Mux {
|
func Routes(s service.Service, t template.Template) *chi.Mux {
|
||||||
router := chi.NewRouter()
|
router := chi.NewRouter()
|
||||||
|
cors := cors.New(cors.Options{
|
||||||
|
AllowedOrigins: []string{"*"},
|
||||||
|
AllowedMethods: []string{"Get"},
|
||||||
|
})
|
||||||
router.Use(
|
router.Use(
|
||||||
middleware.Logger,
|
middleware.Logger,
|
||||||
middleware.Timeout(5*time.Second),
|
middleware.Timeout(5*time.Second),
|
||||||
middleware.DefaultCompress,
|
middleware.DefaultCompress,
|
||||||
middleware.RedirectSlashes,
|
middleware.RedirectSlashes,
|
||||||
middleware.Recoverer,
|
middleware.Recoverer,
|
||||||
|
|
||||||
|
cors.Handler,
|
||||||
)
|
)
|
||||||
|
|
||||||
router.Route("/v1", func(r chi.Router) {
|
router.Route("/v1", func(r chi.Router) {
|
||||||
|
|
Loading…
Reference in a new issue