Files
lincodex/backend/internal/adapter/primary/http/problem/field.go
T

23 lines
958 B
Go

package problem
import (
"context"
"lincodex/backend/internal/adapter/primary/http/api"
)
// InvalidField is the validation_failed problem for one invalid value that
// only the application can detect, such as a stale consent text version. The
// pointer is a JSON Pointer into the location of the value; the body of the
// problem never echoes the value.
func InvalidField(ctx context.Context, location api.ProblemFieldLocation, pointer string) *api.ProblemStatusCode {
return validationProblem(ctx, []api.ProblemFieldError{fieldError(location, pointer, fieldCodeInvalid)})
}
// RateLimited is the 429 problem with the wait before a retry. The wait is
// rounded up to whole seconds, at least one.
func RateLimited(ctx context.Context, waitSeconds int32) *api.TooManyRequestsHeaders {
problem := New(ctx, api.ProblemCodeRateLimited)
return &api.TooManyRequestsHeaders{RetryAfter: api.NewOptInt32(max(waitSeconds, 1)), Response: problem.Response}
}