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


Golang goweb.Context類代碼示例

本文整理匯總了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;未經允許,請勿轉載。