You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2019/05/24 07:45:40 UTC

[GitHub] [servicecomb-kie] wangqj commented on a change in pull request #6: add delete by id string

wangqj commented on a change in pull request #6: add delete by id string
URL: https://github.com/apache/servicecomb-kie/pull/6#discussion_r287248946
 
 

 ##########
 File path: server/resource/v1/kv_resource.go
 ##########
 @@ -150,7 +151,23 @@ func (r *KVResource) FindByLabels(context *restful.Context) {
 
 }
 func (r *KVResource) Delete(context *restful.Context) {
-
+	ids := context.ReadPathParameter("ids")
+	if ids == "" {
+		WriteErrResponse(context, http.StatusBadRequest, ErrIDMustNotEmpty)
+		return
+	}
+	s, err := dao.NewKVService()
+	if err != nil {
+		WriteErrResponse(context, http.StatusInternalServerError, err.Error())
+		return
+	}
+	err = s.Delete(ids)
+	if err != nil {
+		openlogging.Error(fmt.Sprintf("delete ids=%s,err=%s", ids, err.Error()))
+		WriteErrResponse(context, http.StatusInternalServerError, err.Error())
+		return
+	}
+	context.WriteHeader(http.StatusNoContent)
 
 Review comment:
   I am following stricter specifications, of course there is no uniform specification here, 
   I think as long as our style is the same,Do you think 200 is better?
   https://medium.com/@sameira/rest-response-code-for-delete-operation-200-or-204-ee9c72a2dcb2

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services