problem
Entry point for the builder DSL.
json encodes every typed payload added inside block. Pass the application's own instance when its serializersModule or naming strategy matters; see ProblemJson.
See also
Samples
problem {
type = "https://example.net/validation-error"
status = 422
title = "Your request is not valid."
detail = "The 'age' field must be a positive integer."
instance = "/account/12345/msgs/abc"
// Written as a sibling of the standard members, not nested under an "extensions" key.
extension("invalidField", "age")
}Content copied to clipboard
Builds a Problem for this type. detail and instance are the only per-occurrence fields.
Samples
// An application states a problem type's URI, title and status once, in one place.
val outOfCredit =
object : ProblemType {
override val typeUri: String = "https://example.com/probs/out-of-credit"
override val title: String = "You do not have enough credit."
override val status: Int = 403
}
// Only `detail` and `instance` vary per occurrence.
return outOfCredit.problem(detail = "Your current balance is 30, but that costs 50.")Content copied to clipboard