Skip to content

Instantly share code, notes, and snippets.

@rahul-yr
Created July 5, 2022 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahul-yr/d48615186714c6a4f663419d70e85ef7 to your computer and use it in GitHub Desktop.
Save rahul-yr/d48615186714c6a4f663419d70e85ef7 to your computer and use it in GitHub Desktop.
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