本文整理汇总了Golang中code/google/com/p/uedatakuya-goweb/goweb.Context.RespondWithOK方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.RespondWithOK方法的具体用法?Golang Context.RespondWithOK怎么用?Golang Context.RespondWithOK使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类code/google/com/p/uedatakuya-goweb/goweb.Context
的用法示例。
在下文中一共展示了Context.RespondWithOK方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Options
func (cr *Controller) Options(cx *goweb.Context) {
cx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", "*")
cx.ResponseWriter.Header().Set("Access-Control-Allow-Headers", "*")
cx.ResponseWriter.Header().Set("Access-Control-Allow-Methods", "PUT,DELETE,POST,GET,OPTIONS")
cx.RespondWithOK()
}
示例2: DeleteMany
func (cr *Controller) DeleteMany(cx *goweb.Context) {
log.Println("Deleting all diaries...")
c := cr.db.C(COLLECTION)
if _, err := c.RemoveAll(nil); err != nil {
log.Println("Error: %s", err.Error())
cx.RespondWithError(http.StatusForbidden)
return
}
log.Println("Deleted all diaries")
cx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", "*")
cx.RespondWithOK()
}
示例3: Delete
func (cr *Controller) Delete(id string, cx *goweb.Context) {
log.Printf("Deleting a diary id=%s...", id)
c := cr.db.C(COLLECTION)
if err := c.RemoveId(id); err != nil {
log.Println("Error: %s", err.Error())
cx.RespondWithError(http.StatusForbidden)
return
}
log.Printf("Deleted diary id=%s", id)
cx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", "*")
cx.ResponseWriter.Header().Set("Access-Control-Allow-Methods", "DELETE")
cx.RespondWithOK()
}
示例4: UpdateMany
func (cr *Controller) UpdateMany(cx *goweb.Context) {
log.Println("Update all diaries...")
c := cr.db.C(COLLECTION)
var diaries []*Diary
decoder := new(goweb.JsonRequestDecoder)
decoder.Unmarshal(cx, &diaries)
if _, err := c.UpdateAll(nil, diaries); err != nil {
log.Println("Error: %s", err.Error())
cx.RespondWithError(http.StatusForbidden)
return
}
log.Println("Updated all diaries")
cx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", "*")
cx.RespondWithOK()
}
示例5: Update
func (cr *Controller) Update(id string, cx *goweb.Context) {
log.Printf("Update a diary id=%s...", id)
c := cr.db.C(COLLECTION)
var diary *Diary
decoder := new(goweb.JsonRequestDecoder)
decoder.Unmarshal(cx, &diary)
if err := c.UpdateId(id, diary); err != nil {
log.Println("Error: %s", err.Error())
cx.RespondWithError(http.StatusForbidden)
return
}
log.Printf("Updated a diary id=%s", id)
cx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", "*")
cx.ResponseWriter.Header().Set("Access-Control-Allow-Headers", "*")
cx.ResponseWriter.Header().Set("Access-Control-Allow-Methods", "PUT,DELETE,POST,GET,OPTIONS")
cx.RespondWithOK()
}