You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
419 B

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