fix: an unknown redirect status, match or query is refused, not defaulted (WR-17)
The API, MCP, batches and the CSV import copied any value and Normalize
replaced it with the default, answering 201 for a 307 saved as a 301.
RedirectFields.Problems refuses values outside {301, 302, 410}, {exact,
pattern, regex} and {ignore, pass} with value_invalid; the import marks
such rows refused.
This commit is contained in:
@@ -137,6 +137,9 @@ func CreateRedirect(service func() *classes.Service) http.HandlerFunc {
|
||||
if err := decode(r, maxBody, &body); err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
if problems := body.Problems(); len(problems) > 0 {
|
||||
return 0, nil, &classes.ProblemsError{Problems: problems}
|
||||
}
|
||||
row := models.NewRedirect()
|
||||
row.Origin = classes.RedirectOrigin(ctx)
|
||||
body.Apply(&row)
|
||||
@@ -165,6 +168,9 @@ func UpdateRedirect(service func() *classes.Service) http.HandlerFunc {
|
||||
if err := decode(r, maxBody, &body); err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
if problems := body.Problems(); len(problems) > 0 {
|
||||
return 0, nil, &classes.ProblemsError{Problems: problems}
|
||||
}
|
||||
var row models.Redirect
|
||||
var check classes.RedirectCheck
|
||||
err = write(ctx, svc, func(ctx context.Context, tx *gorm.DB) error {
|
||||
|
||||
Reference in New Issue
Block a user