added checker for version in no route api
Mikelle mikhwall@gmail.com
Wed, 24 Mar 2021 23:13:45 +0300
1 files changed,
8 insertions(+),
0 deletions(-)
jump to
M
node/node.go
→
node/node.go
@@ -21,6 +21,7 @@ "errors"
"fmt" "net" "net/http" + "regexp" "sync" "time"@@ -608,6 +609,13 @@ addr string
} func handleNoRoute(c *gin.Context) { + matched, _ := regexp.MatchString(`^/v[0-9]+/`, c.Request.URL.Path) + if !matched { + c.JSON(http.StatusNotFound, gin.H{ + "error": "Version not provided, please provide a valid version in the path such as v1", + }) + return + } c.JSON(http.StatusNotFound, gin.H{ "error": "404 page not found", })