Add basic extraction methods

This commit is contained in:
2024-01-17 18:17:06 +01:00
parent 43ba1bb449
commit 30cb171612
3 changed files with 92 additions and 0 deletions

View File

@@ -56,6 +56,13 @@ func GetPath(resource string, slug string) (string, error) {
return ret.Path, nil
}
func SanitizePath(path string) error {
if strings.Contains(path, "/") || strings.Contains(path, "..") {
return echo.NewHTTPError(http.StatusBadRequest, "Invalid parameter. Can't contains path delimiters or ..")
}
return nil
}
func GetClientId(c echo.Context) (string, error) {
key := c.Request().Header.Get("X-CLIENT-ID")
if key == "" {