Query String Get User Data GinGonic golang framework 12

Query String Get User Data GinGonic golang framework 12

 

Source Code


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

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: