本文整理匯總了Golang中github.com/himanhimao/grafana/pkg/middleware.Context.QueryStrings方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.QueryStrings方法的具體用法?Golang Context.QueryStrings怎麽用?Golang Context.QueryStrings使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/himanhimao/grafana/pkg/middleware.Context
的用法示例。
在下文中一共展示了Context.QueryStrings方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Search
func Search(c *middleware.Context) {
query := c.Query("query")
tags := c.QueryStrings("tag")
starred := c.Query("starred")
limit := c.QueryInt("limit")
if limit == 0 {
limit = 1000
}
searchQuery := search.Query{
Title: query,
Tags: tags,
UserId: c.UserId,
Limit: limit,
IsStarred: starred == "true",
OrgId: c.OrgId,
}
err := bus.Dispatch(&searchQuery)
if err != nil {
c.JsonApiErr(500, "Search failed", err)
return
}
c.JSON(200, searchQuery.Result)
}
示例2: LoginUcenterCallback
func LoginUcenterCallback(c *middleware.Context) {
token := c.QueryStrings("token")
if len(token) == 0 {
c.Handle(500, "ucenter api request error", errors.New("token params error"))
return
}
uclient := ucenter.NewClient(setting.Ucenter.Api_Url, setting.Ucenter.Api_Key, setting.Ucenter.Api_Secret)
if uid, err := service.CheckToken(uclient, strings.Join(token, "")); err != nil {
c.Handle(500, "ucenter api request error", err)
return
} else {
t := reflect.TypeOf(uid)
switch t.Kind() {
case reflect.Bool:
c.Handle(500, "ucenter api request error", errors.New("token is expired or invaild"))
return
case reflect.Float64:
var uidFloat float64 = uid.(float64)
var uidInt int64 = int64(uidFloat)
if user, err := service.GetUserById(uclient, service.Uid(uidInt)); err != nil {
c.Handle(500, "ucenter api request error", err)
return
} else {
//都是登錄狀態了
//首先查詢下用戶是否在數據庫內
queryUser:
userQuery := m.GetUserByLoginQuery{LoginOrEmail: user.Name}
err := bus.Dispatch(&userQuery)
if err != nil {
//如果用戶不存在,則插入數據
cmd := m.CreateUserCommand{}
cmd.Login = user.Name
cmd.Email = user.Email
cmd.Password = setting.AdminPassword //暫用管理員密碼吧
cmd.IsAdmin = false
if err := bus.Dispatch(&cmd); err != nil {
log.Error(3, "Failed to create user"+user.Name, err)
return
}
log.Info("Created user: %v", user.Name)
goto queryUser
}
userModel := userQuery.Result
//記錄狀態
loginUserWithUser(userModel, c)
//跳轉頁麵
c.Redirect(setting.AppSubUrl + "/")
}
}
}
}