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/11/03 14:17:28 UTC

[GitHub] [apisix-dashboard] membphis commented on a change in pull request #655: test: add linter for manager api

membphis commented on a change in pull request #655:
URL: https://github.com/apache/apisix-dashboard/pull/655#discussion_r515876742



##########
File path: api/internal/handler/upstream/upstream_test.go
##########
@@ -51,45 +51,45 @@ func TestUpstream(t *testing.T) {
 		"description": "upstream upstream",
 		"type": "roundrobin",
 		"nodes": [{
-		          "host": "a.a.com",
-		          "port": 80,
-		          "weight": 1
-		      }],
+			"host": "a.a.com",

Review comment:
       do we found those problems with the `linter` tools?

##########
File path: api/internal/handler/upstream/upstream_test.go
##########
@@ -51,45 +51,45 @@ func TestUpstream(t *testing.T) {
 		"description": "upstream upstream",
 		"type": "roundrobin",
 		"nodes": [{
-		          "host": "a.a.com",
-		          "port": 80,
-		          "weight": 1
-		      }],
+			"host": "a.a.com",

Review comment:
       @nic-chen any news?

##########
File path: api/filter/logging.go
##########
@@ -42,16 +43,17 @@ func RequestLogHandler() gin.HandlerFunc {
 
 		param, _ := c.Get("requestBody")
 
-		switch param.(type) {
+		switch paramType := param.(type) {
 		case []byte:
 			param = string(param.([]byte))
+			fmt.Printf("type of param: %#v", paramType)

Review comment:
       change to `log.info`

##########
File path: api/internal/core/store/validate.go
##########
@@ -88,14 +89,17 @@ func NewAPISIXJsonSchemaValidator(jsonPath string) (Validator, error) {
 }
 
 func getPlugins(reqBody interface{}) map[string]interface{} {
-	switch reqBody.(type) {
+	switch bodyType := reqBody.(type) {
 	case *entity.Route:
+		log.Printf("type of reqBody: %#v", bodyType)

Review comment:
       use `log.infof` is better

##########
File path: api/internal/handler/upstream/upstream_test.go
##########
@@ -51,45 +51,45 @@ func TestUpstream(t *testing.T) {
 		"description": "upstream upstream",
 		"type": "roundrobin",
 		"nodes": [{
-		          "host": "a.a.com",
-		          "port": 80,
-		          "weight": 1
-		      }],
+			"host": "a.a.com",

Review comment:
       I got it, we need to process this by handle

##########
File path: api/filter/logging.go
##########
@@ -46,7 +46,7 @@ func RequestLogHandler() gin.HandlerFunc {
 		switch paramType := param.(type) {
 		case []byte:
 			param = string(param.([]byte))
-			fmt.Printf("type of param: %#v", paramType)
+			log.Printf("type of param: %#v", paramType)

Review comment:
       should we use `log.info` here?

##########
File path: api/internal/core/store/validate.go
##########
@@ -194,7 +194,7 @@ func checkConf(reqBody interface{}) error {
 	switch bodyType := reqBody.(type) {
 	case *entity.Route:
 		route := reqBody.(*entity.Route)
-		fmt.Printf("type of reqBody: %#v", bodyType)
+		log.Printf("type of reqBody: %#v", bodyType)

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