Get Request Json Url Param 6 – Gin Gonic Golang Web Framework

Get Request Json Url Param 6 – Gin Gonic Golang Web Framework

 

Source Code

<div>
<div>// get url parameters</div>
<div>// c.param("username")</div>
<div>package main</div>
<div>import "github.com/gin-gonic/gin"</div>
<div>func main() {</div>
<div>    // new router</div>
<div>    r := gin.Default()</div>
<div>    // get request</div>
<div>    r.GET("/:name", func(c *gin.Context) {</div>
<div>        // get name from url and display</div>
<div>        user := c.Param("name")</div>
<div>        // display user data</div>
<div>        //c.String(200, user)</div>
<div>        //c.JSON(200, map[string]string{"firstname": user})</div>
<div>        c.JSON(200, gin.H{"firstname": user})</div>
<div>    })</div>
<div>    r.Run() // port 8080</div>
<div>}</div>
</div>

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

Tony BB
 

TonyBB is a Coach , marketer, hypnotist and a founder of RSKVF Production who specializes in providing simple, affordable, and easy to use solutions for Life.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: