mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 03:16:45 +01:00
added checker for version in no route api
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"regexp"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -608,6 +609,13 @@ type NodeAPI struct { //nolint:golint
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handleNoRoute(c *gin.Context) {
|
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{
|
c.JSON(http.StatusNotFound, gin.H{
|
||||||
"error": "404 page not found",
|
"error": "404 page not found",
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user