Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
case class ErrorResponseBody private(
`type`: URI,
title: String
)
// https://doc.akka.io/docs/akka-http/10.1.3/routing-dsl/rejections.html?language=scala#customising-rejection-http-responses
private val rfc7807RejectionHandler = RejectionHandler.default.mapRejectionResponse {
case res @ HttpResponse(_, _, entity: HttpEntity.Strict, _) =>
val message = entity.data.utf8String
res.copy(
entity = HttpEntity(
CustomMediaTypes.`application/problem+json`,
ErrorResponseBody(new URI("about:blank"), message).toJson.prettyPrint
)
)
case x => x
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.