fix: chainmiddleware

This commit is contained in:
Jon Lundy
2023-01-09 13:09:58 -07:00
parent 0810ec73a0
commit 17569cfb2b
5 changed files with 39 additions and 30 deletions

View File

@@ -2,10 +2,12 @@ package main
import (
"context"
"net/http"
"github.com/sour-is/ev/app/gql"
"github.com/sour-is/ev/internal/lg"
"github.com/sour-is/ev/pkg/gql/resolver"
"github.com/sour-is/ev/pkg/mux"
"github.com/sour-is/ev/pkg/service"
"github.com/sour-is/ev/pkg/slice"
)
@@ -20,10 +22,19 @@ var _ = apps.Register(90, func(ctx context.Context, svc *service.Harness) error
span.RecordError(err)
return err
}
gql.CheckOrigin = func(r *http.Request) bool {
switch r.Header.Get("Origin") {
case "https://ev.sour.is", "https://www.graphqlbin.com", "http://localhost:8080":
return true
default:
return false
}
}
svc.Add(gql)
// svc.Add(mux.RegisterHTTP(func(mux *http.ServeMux) {
// mux.Handle("/", http.RedirectHandler("/playground", http.StatusTemporaryRedirect))
// }))
svc.Add(mux.RegisterHTTP(func(mux *http.ServeMux) {
mux.Handle("/", http.RedirectHandler("/playground", http.StatusTemporaryRedirect))
}))
return nil
})