New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor apis #129
refactor apis #129
Conversation
Signed-off-by: zhulijian <zhulijian1@huawei.com>
server/resource/v1/kv_resource.go
Outdated
if err != nil { | ||
openlogging.Error(fmt.Sprintf("post [%v] err:%s", kvDoc, err.Error())) | ||
if err == session.ErrKVAlreadyExists { | ||
WriteErrResponse(context, http.StatusConflict, err.Error(), common.ContentTypeText) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WriteErrResponse这个函数以前写的有问题,MIME其实应该写死json
@@ -43,11 +43,13 @@ var ( | |||
//KV provide api of KV entity | |||
type KV interface { | |||
//below 3 methods is usually for admin console | |||
Create(ctx context.Context, kv *model.KVDoc) (*model.KVDoc, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议保持createorupdate语义,简洁,内部只需要小改动,而且你不用改UT了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不太好搞,算了
resource层UT别忘了改 |
5a3b59f
to
ed2a1e4
Compare
Signed-off-by: zhulijian <zhulijian1@huawei.com>
修改原因:
Fixes #130
修改内容:
重构kv相关API,包括:
修改后查询有两种方式:
一种: GET /kv/{kv_id} 通过kv_id查询唯一kv,查不到返回404,立即返回,不支持watch。
另一种: GET /kv?key={key}&label=xxxx... 查询符合条件的kv List,与原来API的/kv/{key}?label=xxxx...功能一致,只是参数key从path中移到了query中。查不到返回是200。支持watch。