mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-19 21:46:19 +00:00
28 lines
541 B
Go
28 lines
541 B
Go
package server
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
// hasPrefixes returns true if the string s has any of the given prefixes.
|
|
func hasPrefixes(src string, prefixes ...string) bool {
|
|
for _, prefix := range prefixes {
|
|
if strings.HasPrefix(src, prefix) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
func defaultAPIRequestSkipper(c echo.Context) bool {
|
|
path := c.Path()
|
|
return hasPrefixes(path, "/api")
|
|
}
|
|
|
|
func (*Server) defaultAuthSkipper(c echo.Context) bool {
|
|
path := c.Path()
|
|
return hasPrefixes(path, "/api/v1/auth")
|
|
}
|