Browse Source

added checker for version in no route api

develop^2
Mikelle 3 years ago
parent
commit
4dc44e70c4
1 changed files with 8 additions and 0 deletions
  1. +8
    -0
      node/node.go

+ 8
- 0
node/node.go

@ -21,6 +21,7 @@ import (
"fmt"
"net"
"net/http"
"regexp"
"sync"
"time"
@ -608,6 +609,13 @@ type NodeAPI struct { //nolint:golint
}
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",
})

Loading…
Cancel
Save