Query String Get User Data GinGonic golang framework 12

Query String Get User Data GinGonic golang framework 12

 

Source Code

<div>
<div>// QueryString  // /?user=ali&amp;city=newyork</div>
<div>package main</div>
<div>import "github.com/gin-gonic/gin"</div>
<div>func main() {</div>
<div>    // new server</div>
<div>    r := gin.Default()</div>
<div>    // GET or Post request</div>
<div>    r.GET("/", func(c *gin.Context) {</div>
<div>        // how to get data from user through url? form?</div>
<div>        username := c.DefaultQuery("user", "unknown")</div>
<div>        // if user didn't type ...default value is unknown</div>
<div>        city := c.Query("city") // no need for default value</div>
<div>        c.String(200, "Hello %s from %s", username, city)</div>
<div>    })</div>
<div>    r.Run()</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: