You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/12/24 11:42:52 UTC

[GitHub] [apisix-dashboard] tokers commented on a change in pull request #1110: fix: not allowed to specify `create_time` and `update_time` when create/edit route, service, upstream and consumer

tokers commented on a change in pull request #1110:
URL: https://github.com/apache/apisix-dashboard/pull/1110#discussion_r548504635



##########
File path: api/filter/schema.go
##########
@@ -106,6 +106,18 @@ func parseCert(crt, key string) ([]string, error) {
 }
 
 func handleSpecialField(resource string, reqBody []byte) ([]byte, error) {
+	var bodyMap map[string]interface{}
+	err := json.Unmarshal(reqBody, &bodyMap)
+	if err != nil {
+		return reqBody, fmt.Errorf("read request body failed: %s", err)
+	}
+	if _, ok := bodyMap["create_time"]; ok {
+		return reqBody, fmt.Errorf("we don't accept create_time from client")

Review comment:
       Here we don't add any parameters, just use errors.New is fine.

##########
File path: api/filter/schema.go
##########
@@ -106,6 +106,18 @@ func parseCert(crt, key string) ([]string, error) {
 }
 
 func handleSpecialField(resource string, reqBody []byte) ([]byte, error) {
+	var bodyMap map[string]interface{}
+	err := json.Unmarshal(reqBody, &bodyMap)
+	if err != nil {
+		return reqBody, fmt.Errorf("read request body failed: %s", err)
+	}
+	if _, ok := bodyMap["create_time"]; ok {
+		return reqBody, fmt.Errorf("we don't accept create_time from client")
+	}
+	if _, ok := bodyMap["update_time"]; ok {
+		return reqBody, fmt.Errorf("we don't accept update_time from client")

Review comment:
       Ditto.




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