當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Request.Param方法代碼示例

本文整理匯總了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)
}
開發者ID:speedland,項目名稱:service,代碼行數:17,代碼來源:entity.go

示例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
}
開發者ID:speedland,項目名稱:service,代碼行數:31,代碼來源:member_handler.go


注:本文中的lib/wcg.Request.Param方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。