~bigbes/core-go

8f9aa9d5ef30f9507d826b9451fdf7fc083f2da3 — Drew DeVault 1 year, 9 months ago 46a4ad6
server: fix playground on config.Debug

A recent change made it so that the playground required authentication
to access in debug mode; this moves it under the other auth-free
endpoints.
1 files changed, 6 insertions(+), 4 deletions(-)

M server/server.go
M server/server.go => server/server.go +6 -4
@@ 103,16 103,18 @@ func (server *Server) WithSchema(
		handler.RecoverFunc(EmailRecover),
		handler.UploadMaxSize(1073741824)) // 1 GiB (TODO: configurable?)

	if config.Debug {
		server.router.Handle("/",
			playground.Handler("GraphQL playground", "/query"))
	}
	server.router.Handle("/query", srv)

	// These don't need auth or any other middleware - just log and process
	server.root.Group(func(r chi.Router) {
		r.Use(middleware.RealIP)
		r.Use(middleware.Logger)

		if config.Debug {
			play := playground.Handler("GraphQL playground", "/query")
			r.Handle("/", play)
		}

		r.Handle("/query/metrics", promhttp.Handler())
		r.Get("/query/api-meta.json", func(w http.ResponseWriter, r *http.Request) {
			info := struct {