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



##########
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:
       `if _, ok := route["status"]; !ok {` is checking whether there is a 
`status` field in the route config, if not, use the default value, otherwise 
use the submitted `status` value.
   




----------------------------------------------------------------
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