arnaucube
arnaucube/hermez-nodePublic Self-hosted repository
hermez-node/api/noroute.go
api/noroute.goRaw
 1package api
 2
 3import (
 4	"net/http"
 5	"regexp"
 6
 7	"github.com/gin-gonic/gin"
 8)
 9
10func (a *API) noRoute(c *gin.Context) {
11	matched, _ := regexp.MatchString(`^/v[0-9]+/`, c.Request.URL.Path)
12	if !matched {
13		c.JSON(http.StatusNotFound, gin.H{
14			"error": "Version not provided, please provide a valid version in the path such as v1",
15		})
16		return
17	}
18	c.JSON(http.StatusNotFound, gin.H{
19		"error": "404 page not found",
20	})
21}