beego acquired url parameters and the way

The following are the full implementation of default under the controller

  • Gets referer current request

    fmt.Println(this.Ctx.Request.Referer())
    输出:http://localhost:8080/swagger/

  • Get the current uri,

    fmt.Println(this.Ctx.Request.RequestURI)
    输出: /v1/weather/?longitude=1&latitude=2

  • Get the query parameter, the form /? Longitude = 1 & latitude = 2

    fmt.Println(this.Ctx.Input.Query("longitude"))
    fmt.Println(this.Ctx.Input.Query("latitude"))

  • Get the path parameter of the form http: // localhost: 8080 / userinfo / {uid} This
    fmt.Println (u.GetString ( ": uid" ))
    This is the string, if other types of reference
    GetString(key string) string GetStrings(key string) []string GetInt(key string) (int64, error) GetBool(key string) (bool, error) GetFloat(key string) (float64, error)

Guess you like

Origin www.cnblogs.com/lz0925/p/11856084.html