liuxiran commented on a change in pull request #1081:
URL: https://github.com/apache/apisix-dashboard/pull/1081#discussion_r546309863



##########
File path: api/filter/schema.go
##########
@@ -136,6 +144,25 @@ func handleSpecialField(resource string, reqBody []byte) 
([]byte, error) {
        return reqBody, nil
 }
 
+func handleDefaultValue(resource string, reqBody []byte) ([]byte, error) {
+       // go jsonschema lib doesn't support setting default values, so we need 
to set for some fields necessary
+       if resource == "routes" {
+               var route map[string]interface{}
+               err := json.Unmarshal(reqBody, &route)
+               if err != nil {
+                       return reqBody, fmt.Errorf("read request body failed: 
%s", err)
+               }
+               if _, ok := route["status"]; !ok {

Review comment:
       > 2. The `status` now is enabled by default after created, if that route 
has something wrong, we have to offline it after published? 🤔 I'm not sure if 
it's ok.
   
   1. we will pass `status: 1` when create a route via fe, if user did not 
disable this field
   2. create route without `status`,  golang will treat this field as 0, which 
goes against the original intent defined in APISIX so @nic-chen add these code 
to solve this problem.
   
   
   




----------------------------------------------------------------
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:
[email protected]


Reply via email to