some cleanup and gqlgen setup
This commit is contained in:
34
graph/server/main.go
Normal file
34
graph/server/main.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"gitserver.in/patialtech/mux"
|
||||
"gitserver.in/patialtech/rano/graph"
|
||||
"gitserver.in/patialtech/rano/pkg/logger"
|
||||
)
|
||||
|
||||
func main() {
|
||||
r := mux.NewRouter()
|
||||
// graphiql
|
||||
r.Get("/graphiql", graph.GraphiQL("/query"))
|
||||
// graph query
|
||||
r.Post("/query", graph.Query)
|
||||
|
||||
// catch all
|
||||
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Write([]byte("hello there"))
|
||||
})
|
||||
|
||||
port := os.Getenv("GRAPH_PORT")
|
||||
if port == "" {
|
||||
port = "4001"
|
||||
}
|
||||
|
||||
r.Serve(func(srv *http.Server) error {
|
||||
srv.Addr = ":" + port
|
||||
logger.Info("graph server listening on %s", srv.Addr)
|
||||
return srv.ListenAndServe()
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user