Get Request Json Url Param 6 – Gin Gonic Golang Web Framework
Get Request Json Url Param 6 – Gin Gonic Golang Web Framework
Source Code
//[sourcecode lang=”go” autolinks=”false” classname=”myclass” collapse=”false” firstline=”1″ gutter=”true” highlight=”1-3,6,9″ htmlscript=”false” light=”false” padlinenumbers=”false” smarttabs=”true” tabsize=”4″ toolbar=”false” title=”Source Code main.go”]
// get url parameters
// c.param("username")
package main
import "github.com/gin-gonic/gin"
func main() {
// new router
r := gin.Default()
// get request
r.GET("/:name", func(c *gin.Context) {
// get name from url and display
user := c.Param("name")
// display user data
//c.String(200, user)
//c.JSON(200, map[string]string{"firstname": user})
c.JSON(200, gin.H{"firstname": user})
})
r.Run() // port 8080
}
[/sourcecode]
golang gingonic framework videos tutorials series
TAGS#
gin gonic tutorial
gin-gonic / examples
gin-gonic documentation
gin framework tutorial
gin web framework
gin router
golang gin context
gin router group
###Buy Me a Coffee https://www.buymeacoffee.com/khan1