本文整理汇总了Golang中libs/goweb.Context.RespondWithData方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.RespondWithData方法的具体用法?Golang Context.RespondWithData怎么用?Golang Context.RespondWithData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libs/goweb.Context
的用法示例。
在下文中一共展示了Context.RespondWithData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: UserName
func UserName(cx *goweb.Context) {
c := appengine.NewContext(cx.Request)
u := user.Current(c)
if u != nil {
cx.RespondWithData(u.String())
} else {
cx.RespondWithData("")
}
}
示例2: Delete
func (cr *PublicationsApiController) Delete(id string, cx *goweb.Context) {
if NotLoggedIn(cx) {
cx.RespondWithStatus(UNAUTHORISED_HTTP_STATUS)
return
}
c := appengine.NewContext(cx.Request)
intID, err := strconv.Atoi(id)
if err != nil {
c.Infof("Invalid key while deleting: key = %v", id)
return
}
pubs := model.PubsDAO.DeletePublication(int64(intID), c)
cx.RespondWithData(pubs)
}
示例3: LoginLogoutURLs
func LoginLogoutURLs(cx *goweb.Context) {
c := appengine.NewContext(cx.Request)
loginURL, err := user.LoginURL(c, "/")
if err != nil {
cx.RespondWithStatus(400)
return
}
logoutURL, err := user.LogoutURL(c, "/")
if err != nil {
cx.RespondWithStatus(400)
return
}
cx.RespondWithData(URLs{loginURL, logoutURL})
}
示例4: Create
func (cr *PublicationsApiController) Create(cx *goweb.Context) {
if NotLoggedIn(cx) {
cx.RespondWithStatus(UNAUTHORISED_HTTP_STATUS)
return
}
c := appengine.NewContext(cx.Request)
var pub model.Publication
// Create an object from POST request
err := cx.Fill(&pub)
if err != nil {
c.Errorf("Form-decoder: %v", err)
return
}
pubs := model.PubsDAO.CreatePublication(pub, c)
cx.RespondWithData(pubs)
}
示例5: ReadMany
func (cr *PublicationsApiController) ReadMany(cx *goweb.Context) {
c := appengine.NewContext(cx.Request)
pubs := model.PubsDAO.GetPublications(c)
cx.RespondWithData(pubs)
}