Created
August 12, 2022 14:21
-
-
Save destinio/099a589017a16b3310e2127796c393ee to your computer and use it in GitHub Desktop.
Basic Golang webserver
This file contains hidden or 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 ( | |
"github.com/gin-gonic/gin" | |
) | |
func main() { | |
router := gin.Default() | |
router.GET("/", func(c *gin.Context) { | |
c.JSON(200, gin.H{ "msg": "Hello" }) | |
}) | |
router.GET("/api/people/:id", func(c *gin.Context) { | |
id := c.Param("id") | |
c.JSON(200, gin.H{ "msg": id }) | |
}) | |
// http.ListenAndServe(":1337", router) | |
router.Run(":1337") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment