Skip to content

Instantly share code, notes, and snippets.

@rahul-yr
Created July 5, 2022 04:25
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
This is the entry point for Todo GraphQL server
package main
import (
"os"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"github.com/rahul-yr/learn-go-grapql/graph"
)
// main is the entry point for the application.
func main() {
// gin setup
gin.SetMode(gin.ReleaseMode)
// create gin engine
router := gin.Default()
// enable cors
router.Use(cors.Default())
// create graphql endpoint
router.POST("/todo", graph.TodoGraphRouter)
// add webserver port
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
// start webserver
router.Run(":" + port)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment