This is an automated email from the ASF dual-hosted git repository.
littlecui pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/incubator-servicecomb-service-center.git
The following commit(s) were added to refs/heads/master by this push:
new 839c408 SCB-622 Compatible with old version (#360)
839c408 is described below
commit 839c4081646955639d0ac008c6079f6a6796168f
Author: little-cui <[email protected]>
AuthorDate: Wed May 30 12:50:02 2018 +0800
SCB-622 Compatible with old version (#360)
---
server/rest/controller/v4/microservice_controller.go | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/server/rest/controller/v4/microservice_controller.go
b/server/rest/controller/v4/microservice_controller.go
index 5efe78a..ce578c7 100644
--- a/server/rest/controller/v4/microservice_controller.go
+++ b/server/rest/controller/v4/microservice_controller.go
@@ -26,9 +26,10 @@ import (
"github.com/apache/incubator-servicecomb-service-center/server/rest/controller"
"io/ioutil"
"net/http"
- "strings"
)
+var trueOrFalse = map[string]bool{"true": true, "false": false, "1": true,
"0": false}
+
type MicroServiceService struct {
//
}
@@ -86,15 +87,18 @@ func (this *MicroServiceService) Update(w
http.ResponseWriter, r *http.Request)
}
func (this *MicroServiceService) Unregister(w http.ResponseWriter, r
*http.Request) {
- force := r.URL.Query().Get("force")
serviceId := r.URL.Query().Get(":serviceId")
- if force != "false" && force != "true" && strings.TrimSpace(force) !=
"" {
+ force := r.URL.Query().Get("force")
+
+ b, ok := trueOrFalse[force]
+ if force != "" && !ok {
controller.WriteError(w, scerr.ErrInvalidParams, "parameter
force must be false or true")
return
}
+
request := &pb.DeleteServiceRequest{
ServiceId: serviceId,
- Force: force == "true",
+ Force: b,
}
resp, _ := core.ServiceAPI.Delete(r.Context(), request)
controller.WriteResponse(w, resp.Response, nil)
--
To stop receiving notification emails like this one, please contact
[email protected].