Get request Json map[string]interface{}{} – Gin Gonic Golang Web Framwork 3

Get request Json map[string]interface{}{} – Gin Gonic Golang Web Framwork 3

 

Source Code

<div>
<div>// Get Request sending - map[string]interface{}{}</div>
<div>package main</div>
<div>import "github.com/gin-gonic/gin"</div>
<div>func main() {</div>
<div>    // create new router/server</div>
<div>    r := gin.Default()</div>
<div>    // get request method</div>
<div>    // first value for path/url</div>
<div>    // 2nd for function/callback</div>
<div>    r.GET("/", func(c *gin.Context) {</div>
<div>        // send json data via JSON()</div>
<div>        // first value is status Code , 2nd is our data</div>
<div>        c.JSON(200, map[string]interface{}{</div>
<div>            "Hero":        "here is hero",</div>
<div>            "geo":         "Here is geo",</div>
<div>            "third value": "You can send anything",</div>
<div>        })</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: