~edwargix/git.sr.ht

67d762e731e384147caf728ecc9230a1d47db902 — Drew DeVault 5 years ago daab41b
api: add debug option to server binary
1 files changed, 6 insertions(+), 1 deletions(-)

M api/server.go
M api/server.go => api/server.go +6 -1
@@ 27,6 27,7 @@ func main() {
	var (
		addr   string = defaultAddr
		config ini.File
		debug  bool
		err    error
	)
	opts, _, err := getopt.Getopts(os.Args, "b:d")


@@ 37,6 38,8 @@ func main() {
		switch opt.Option {
		case 'b':
			addr = opt.Value
		case 'd':
			debug = true
		}
	}



@@ 71,7 74,9 @@ func main() {
		Resolvers: &graph.Resolver{DB: db},
	}))

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

	log.Printf("running on %s", addr)