示例#1
0
文件: server.go 项目: maxzerbini/ovo
func (srv *Server) post(c *gin.Context) {
	var kv model.OvoKVRequest
	if c.BindJSON(&kv) == nil {
		obj := model.NewMetaDataObj(&kv)
		srv.keystorage.Put(obj)
		srv.outcmdproc.Enqueu(&command.Command{OpCode: "put", Obj: obj.MetaDataUpdObj()})
		c.JSON(http.StatusOK, model.NewOvoResponse("done", "0", nil))
	} else {
		c.JSON(http.StatusBadRequest, model.NewOvoResponse("error", "10", nil))
	}
}
示例#2
0
文件: server.go 项目: maxzerbini/ovo
func (srv *Server) deleteValueIfEqual(c *gin.Context) {
	key := c.Param("key")
	var kv model.OvoKVRequest
	if c.BindJSON(&kv) == nil {
		obj := model.NewMetaDataObj(&kv)
		obj.Key = key
		err := srv.keystorage.DeleteValueIfEqual(obj)
		if err == nil {
			srv.outcmdproc.Enqueu(&command.Command{OpCode: "delete", Obj: obj.MetaDataUpdObj()})
			c.JSON(http.StatusOK, model.NewOvoResponse("done", "0", nil))
		} else {
			c.JSON(http.StatusForbidden, model.NewOvoResponse("error", "103", nil))
		}
	} else {
		c.JSON(http.StatusBadRequest, model.NewOvoResponse("error", "10", nil))
	}
}