Created
July 5, 2022 04:25
-
-
Save rahul-yr/d48615186714c6a4f663419d70e85ef7 to your computer and use it in GitHub Desktop.
This is the entry point for Todo GraphQL server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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