Skip to content

Instantly share code, notes, and snippets.

@destinio
Created August 12, 2022 14:21
Show Gist options
  • Save destinio/099a589017a16b3310e2127796c393ee to your computer and use it in GitHub Desktop.
Save destinio/099a589017a16b3310e2127796c393ee to your computer and use it in GitHub Desktop.
Basic Golang webserver
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