aboutsummaryrefslogtreecommitdiffstats
path: root/graphql/handler.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-08-21 18:46:53 +0200
committerMichael Muré <batolettre@gmail.com>2018-08-21 19:13:08 +0200
commit6d7dc465d881d0d04b01dfb6e09870346216d2d0 (patch)
treefbbce01c6b7634556303a3d917d1036767280d17 /graphql/handler.go
parent942178288d657202b3f7afd386b319a245afbb7e (diff)
downloadgit-bug-6d7dc465d881d0d04b01dfb6e09870346216d2d0.tar.gz
cache: lock the repo with a pid file; automatic cleaning
Diffstat (limited to 'graphql/handler.go')
-rw-r--r--graphql/handler.go20
1 files changed, 16 insertions, 4 deletions
diff --git a/graphql/handler.go b/graphql/handler.go
index 507cb508..b452d828 100644
--- a/graphql/handler.go
+++ b/graphql/handler.go
@@ -10,10 +10,22 @@ import (
"net/http"
)
-func NewHandler(repo repository.Repo) http.Handler {
- backend := resolvers.NewBackend()
+type Handler struct {
+ http.HandlerFunc
+ *resolvers.Backend
+}
+
+func NewHandler(repo repository.Repo) (Handler, error) {
+ h := Handler{
+ Backend: resolvers.NewBackend(),
+ }
+
+ err := h.Backend.RegisterDefaultRepository(repo)
+ if err != nil {
+ return Handler{}, err
+ }
- backend.RegisterDefaultRepository(repo)
+ h.HandlerFunc = handler.GraphQL(graph.NewExecutableSchema(h.Backend))
- return handler.GraphQL(graph.NewExecutableSchema(backend))
+ return h, nil
}