arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
added checker for version in no route api
Mikelle mikhwall@gmail.com
Wed, 24 Mar 2021 23:13:45 +0300
commit

4dc44e70c48d38ba830d5f7bae4d1225eb14f381

parent

f07fd82822d45461ec58cda75bccf34c17bd2897

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", })