github.com/deliveroo/gqlgen@v0.7.2/example/todo/server/server.go (about)

     1  package main
     2  
     3  import (
     4  	"context"
     5  	"errors"
     6  	"log"
     7  	"net/http"
     8  	"runtime/debug"
     9  
    10  	"github.com/99designs/gqlgen/example/todo"
    11  	"github.com/99designs/gqlgen/handler"
    12  )
    13  
    14  func main() {
    15  	http.Handle("/", handler.Playground("Todo", "/query"))
    16  	http.Handle("/query", handler.GraphQL(
    17  		todo.NewExecutableSchema(todo.New()),
    18  		handler.RecoverFunc(func(ctx context.Context, err interface{}) error {
    19  			// send this panic somewhere
    20  			log.Print(err)
    21  			debug.PrintStack()
    22  			return errors.New("user message on panic")
    23  		}),
    24  	))
    25  	log.Fatal(http.ListenAndServe(":8081", nil))
    26  }