@@ -50,13 +50,15 @@ func (app *App) HandleAPIError(err error, c *echo.Context) error {
5050 }
5151
5252 if code == http .StatusNotFound {
53- path_ := (* c ).Request ().URL .Path
54- if version , ok := IsDeprecatedAPIPath (path_ ).Get (); ok {
55- switch version {
56- case 1 :
57- message = "Version 1 of this API was deprecated in release 3.0.0."
58- default :
59- message = fmt .Sprintf ("Version %d of this API is deprecated." , version )
53+ baseRelative , err := app .BaseRelativePath ((* c ).Request ().URL .Path )
54+ if err == nil {
55+ if version , ok := IsDeprecatedAPIPath (baseRelative ).Get (); ok {
56+ switch version {
57+ case 1 :
58+ message = "Version 1 of this API was deprecated in release 3.0.0."
59+ default :
60+ message = fmt .Sprintf ("Version %d of this API is deprecated." , version )
61+ }
6062 }
6163 }
6264 }
@@ -78,25 +80,12 @@ func (app *App) HandleAPIError(err error, c *echo.Context) error {
7880 return (* c ).JSON (code , APIError {Message : message })
7981}
8082
81- func IsAPIPath (path_ string ) bool {
82- if path_ == "/" {
83- return false
84- }
85-
86- split := strings .Split (path_ , "/" )
87- if len (split ) >= 3 && split [1 ] == "drasl" && split [2 ] == "api" {
88- return true
89- }
90-
91- return false
92- }
93-
94- func IsDeprecatedAPIPath (path_ string ) mo.Option [int ] {
95- if path_ == "/" {
83+ func IsDeprecatedAPIPath (baseRelative string ) mo.Option [int ] {
84+ if baseRelative == "/" {
9685 return mo .None [int ]()
9786 }
9887
99- split := strings .Split (path_ , "/" )
88+ split := strings .Split (baseRelative , "/" )
10089 if len (split ) >= 3 && split [1 ] == "drasl" && split [2 ] == "api" {
10190 re := regexp .MustCompile (`v(\d+)` )
10291 match := re .FindStringSubmatch (split [3 ])
0 commit comments