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



##########
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:
       Just to make sure, 
   1. `!ok` will be truthy when `ok` is `falsy`, If one route is not enabled, 
then after this filter, the status will be?
   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.




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