Add base acc server
This commit is contained in:
29
cmd/acc/main.go
Normal file
29
cmd/acc/main.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"git.front.kjuulh.io/kjuulh/acc-server/generated/graphql"
|
||||
intgraphql "git.front.kjuulh.io/kjuulh/acc-server/internal/graphql"
|
||||
"github.com/99designs/gqlgen/graphql/handler"
|
||||
"github.com/99designs/gqlgen/graphql/playground"
|
||||
)
|
||||
|
||||
const defaultPort = "8080"
|
||||
|
||||
func main() {
|
||||
port := os.Getenv("PORT")
|
||||
if port == "" {
|
||||
port = defaultPort
|
||||
}
|
||||
|
||||
srv := handler.NewDefaultServer(graphql.NewExecutableSchema(intgraphql.NewResolver()))
|
||||
|
||||
http.Handle("/", playground.Handler("GraphQL playground", "/query"))
|
||||
http.Handle("/query", srv)
|
||||
|
||||
log.Printf("connect to http://localhost:%s/ for GraphQL playground", port)
|
||||
log.Fatal(http.ListenAndServe(":"+port, nil))
|
||||
}
|
Reference in New Issue
Block a user