• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang goweb.Context类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中code/google/com/p/goweb/goweb.Context的典型用法代码示例。如果您正苦于以下问题:Golang Context类的具体用法?Golang Context怎么用?Golang Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Context类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: Update

func (cr *DataController) Update(id string, 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")
	data := new(dataContainer)
	data.Model = cx.PathParams["model"]
	errs := cx.Fill(&data.Data)
	if errs != nil {
		log.Print(errs)
		cx.RespondWithError(500)
	} else {
		bucket, berr := couchbase.GetBucket("http://localhost:8091/", "default", "mking.me")
		if berr != nil {
			log.Print(berr)
			cx.WriteResponse(data, http.StatusInternalServerError)
		} else {
			data.Data["id"] = id
			errr := bucket.Set(id, 0, data)
			if errr != nil {
				log.Print(errr)
				cx.WriteResponse(data.Data, http.StatusInternalServerError)
			} else {
				cx.WriteResponse(data.Data, http.StatusOK)
			}
		}
	}
}
开发者ID:mattking17,项目名称:shiftbase,代码行数:27,代码来源:data_controller.go


示例2: Options

// for OPTIONS /api
func (cr *DataController) Options(cx *goweb.Context) {
	log.Print("wat")

	cx.ResponseWriter.Header().Set("Access-Control-Allow-Headers", "*")
	cx.ResponseWriter.Header().Set("Access-Control-Allow-Methods", "GET,POST,PUT,DELETE,OPTIONS")
	cx.RespondWithOK()
}
开发者ID:mattking17,项目名称:shiftbase,代码行数:8,代码来源:data_controller.go


示例3: ReadMany

func (cr *ManifestController) ReadMany(cx *goweb.Context) {
	cx.ResponseWriter.Header().Set("Access-Control-Allow-Origin", "*")
	bucket, err := couchbase.GetBucket("http://localhost:8091/", "default", "mking.me")
	if err != nil {
		log.Print(err)
	}

	rv := make(map[string]interface{})
	rv["stale"] = false
	vres, _ := bucket.View("manifest", "all", rv)
	if len(vres.Rows) > 0 {
		cx.WriteResponse(vres.Rows[0].Value, http.StatusOK)
	} else {
		cx.WriteResponse(make([]string, 0), http.StatusOK)
	}
}
开发者ID:mattking17,项目名称:shiftbase,代码行数:16,代码来源:manifest_controller.go


示例4: Delete

func (cr *DataController) Delete(id string, 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", "DELETE")
	bucket, err := couchbase.GetBucket("http://localhost:8091/", "default", "mking.me")
	if err != nil {
		log.Print(err)
		cx.WriteResponse("", http.StatusInternalServerError)
	}
	rv := new(dataContainer)
	bucket.Get(id, &rv)
	derr := bucket.Delete(id)
	if derr != nil {
		log.Print(derr)
		cx.WriteResponse(rv.Data, http.StatusInternalServerError)
	} else {
		cx.WriteResponse(rv.Data, http.StatusOK)
	}
}
开发者ID:mattking17,项目名称:shiftbase,代码行数:19,代码来源:data_controller.go


示例5: Read

func (cr *ManifestController) Read(id string, cx *goweb.Context) {

	bucket, err := couchbase.GetBucket("http://localhost:8091/", "default", "mking.me")
	if err != nil {
		log.Print(err)
	}
	rv := new(manifestData)
	gerr := bucket.Get(id, &rv)
	if gerr != nil {
		cx.WriteResponse(rv, http.StatusNotFound)
	} else {
		if rv != nil {
			cx.WriteResponse(rv, http.StatusOK)
		} else {
			cx.WriteResponse(rv, http.StatusNotFound)
		}
	}

}
开发者ID:mattking17,项目名称:shiftbase,代码行数:19,代码来源:manifest_controller.go


示例6: Read

func (cr *DataController) Read(id string, 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", "GET")
	bucket, err := couchbase.GetBucket("http://localhost:8091/", "default", "mking.me")
	if err != nil {
		log.Print(err)
	}
	rv := new(dataContainer)
	gerr := bucket.Get(id, &rv)
	if gerr != nil {
		cx.WriteResponse(rv.Data, http.StatusNotFound)
	} else {
		if rv != nil {
			cx.WriteResponse(rv.Data, http.StatusOK)
		} else {
			cx.WriteResponse(rv.Data, http.StatusNotFound)
		}
	}
}
开发者ID:mattking17,项目名称:shiftbase,代码行数:20,代码来源:data_controller.go


示例7: ReadMany

func (cr *DataController) ReadMany(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", "GET")
	bucket, err := couchbase.GetBucket("http://localhost:8091/", "default", "mking.me")
	if err != nil {
		log.Print(err)
	}

	rv := make(map[string]interface{})
	rv["stale"] = false
	vres, verr := bucket.View(cx.PathParams["model"], "all", rv)
	if verr != nil {
		cx.WriteResponse(make([]string, 0), http.StatusNotFound)
	} else {
		if len(vres.Rows) > 0 {
			cx.WriteResponse(vres.Rows[0].Value, http.StatusOK)
		} else {
			cx.WriteResponse(make([]string, 0), http.StatusOK)
		}
	}
}
开发者ID:mattking17,项目名称:shiftbase,代码行数:22,代码来源:data_controller.go


示例8: UpdateMany

func (cr *DataController) UpdateMany(cx *goweb.Context) {
	cx.RespondWithStatus(http.StatusNotImplemented)
}
开发者ID:mattking17,项目名称:shiftbase,代码行数:3,代码来源:data_controller.go


示例9: Fill

func (p *Product) Fill(cx *goweb.Context) {
	cx.Fill(&p)
}
开发者ID:intel352,项目名称:go-play,代码行数:3,代码来源:models.go


示例10: DeleteMany

func (cr *ManifestController) DeleteMany(cx *goweb.Context) {
	cx.RespondWithStatus(http.StatusNotImplemented)
}
开发者ID:mattking17,项目名称:shiftbase,代码行数:3,代码来源:manifest_controller.go



注:本文中的code/google/com/p/goweb/goweb.Context类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang gwu.NewLabel函数代码示例发布时间:2022-05-24
下一篇:
Golang vtsrv.Req类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap