本文整理汇总了Golang中lib/wcg.Request.Param方法的典型用法代码示例。如果您正苦于以下问题:Golang Request.Param方法的具体用法?Golang Request.Param怎么用?Golang Request.Param使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib/wcg.Request
的用法示例。
在下文中一共展示了Request.Param方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: processEntityPut
func processEntityPut(req *wcg.Request, put *entities.Put, keyParams string, create bool) response.Response {
key := req.Param(keyParams)
_, ent := put.Kind().Get().Key(key).UseDefaultIfNil(create).MustOne(req)
if ent == nil {
return response.APINotFound
}
if req.HTTPRequest().Form == nil {
req.Logger.Warnf("You should use ParseForm middleware to avoid the error in EntityPut|EntityPutOrCreate")
return response.InternalServerError(req, ErrInvalidFormParameters).(response.Response)
}
err := put.Kind().UpdateEntityFromForm(ent, req.HTTPRequest().Form)
if err != nil {
return response.BadRequest(req, ErrInvalidFormParameters)
}
_, ent_ := put.Key(key).MustUpdate(req, ent)
return response.NewJSONResponseWithStatus(ent_, 200)
}
示例2: findArtistAndMember
func findArtistAndMember(req *wcg.Request) *hplink.Member {
var artist *hplink.Artist
var member *hplink.Member
var funcs = []func(){
func() {
_, ent := entities.Artist.Get().Key(
req.Param(paramKeyArtist),
).MustOne(req)
if ent != nil {
artist = ent.(*hplink.Artist)
}
},
func() {
_, ent := entities.Member.Get().Key(
fmt.Sprintf("%s.%s", req.Param(paramKeyArtist), req.Param(paramKeyMember)),
).MustOne(req)
if ent != nil {
member = ent.(*hplink.Member)
}
},
}
iterator.ParallelSlice(funcs, func(i int, v func()) error {
v()
return nil
})
if artist == nil || member == nil {
return nil
}
member.Artist = artist
return member
}