feat: add layer definition api
Some checks are pending
Cadoles/bouncer/pipeline/pr-develop Build started...
Cadoles/bouncer/pipeline/head This commit looks good

This commit is contained in:
2024-05-17 15:44:28 +02:00
parent 7456dba96f
commit 449fb69c02
42 changed files with 698 additions and 1270 deletions

View File

@ -285,7 +285,7 @@ func getStringSliceValues(w http.ResponseWriter, r *http.Request, param string,
return defaultValue, true
}
func getStringableSliceValues[T ~string](w http.ResponseWriter, r *http.Request, param string, defaultValue []T, validate func(string) (T, error)) ([]T, bool) {
func getStringableSliceValues[T ~string](w http.ResponseWriter, r *http.Request, param string, defaultValue []T, transform func(string) (T, error)) ([]T, bool) {
rawValue := r.URL.Query().Get(param)
if rawValue != "" {
@ -293,7 +293,7 @@ func getStringableSliceValues[T ~string](w http.ResponseWriter, r *http.Request,
values := make([]T, 0, len(rawValues))
for _, rv := range rawValues {
v, err := validate(rv)
v, err := transform(rv)
if err != nil {
logAndCaptureError(r.Context(), "could not parse ids slice param", errors.WithStack(err))
api.ErrorResponse(w, http.StatusBadRequest, api.ErrCodeMalformedRequest, nil)