play-rfc7807


License

License

MIT
GroupId

GroupId

de.lenabrueder
ArtifactId

ArtifactId

play-rfc7807_2.12
Last Version

Last Version

2.6.1
Release Date

Release Date

Type

Type

jar
Description

Description

play-rfc7807
play-rfc7807
Project URL

Project URL

https://github.com/lenalebt/play-rfc7807
Project Organization

Project Organization

de.lenabrueder
Source Code Management

Source Code Management

https://github.com/lenalebt/play-rfc7807

Download play-rfc7807_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/de.lenabrueder/play-rfc7807_2.12/ -->
<dependency>
    <groupId>de.lenabrueder</groupId>
    <artifactId>play-rfc7807_2.12</artifactId>
    <version>2.6.1</version>
</dependency>
// https://jarcasting.com/artifacts/de.lenabrueder/play-rfc7807_2.12/
implementation 'de.lenabrueder:play-rfc7807_2.12:2.6.1'
// https://jarcasting.com/artifacts/de.lenabrueder/play-rfc7807_2.12/
implementation ("de.lenabrueder:play-rfc7807_2.12:2.6.1")
'de.lenabrueder:play-rfc7807_2.12:jar:2.6.1'
<dependency org="de.lenabrueder" name="play-rfc7807_2.12" rev="2.6.1">
  <artifact name="play-rfc7807_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='de.lenabrueder', module='play-rfc7807_2.12', version='2.6.1')
)
libraryDependencies += "de.lenabrueder" % "play-rfc7807_2.12" % "2.6.1"
[de.lenabrueder/play-rfc7807_2.12 "2.6.1"]

Dependencies

compile (2)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.4
com.sksamuel.scapegoat : scalac-scapegoat-plugin_2.12 jar 1.3.1

provided (3)

Group / Artifact Type Version
com.typesafe.play : play_2.12 jar 2.6.10
com.typesafe.play : play-json_2.12 jar 2.6.8
com.google.inject : guice jar 4.1.0

test (2)

Group / Artifact Type Version
org.scalatest : scalatest_2.12 jar 3.0.4
org.scalatestplus.play : scalatestplus-play_2.12 jar 3.1.2

Project Modules

There are no modules declared in this project.

application/problem+json (RFC7807) plugin for Play framework

This plugin adds easy support for RFC7807 to your application.

Usage

add the dependency

libraryDependencies += "de.lenabrueder" %% "play-rfc7807" % "2.6.1"

to your build.sbt. Versioning follows play version in major and minor versions, patch version is up to the library. If you want to use the error handler as well, add

play.http.errorHandler = "de.lenabrueder.rfc7807.ProblemErrorHandler"

to your application.conf.

After that, you can use it through adding import de.lenabrueder.rfc7807.PlayIntegration._ to your controller. This adds some implicit functions to your Results, which allow you to do the following:

InternalServerError.withProblem("cannot store flight")
NotFound.asProblem
Forbidden.withProblem(new RuntimeException("something went wrong"))
Unauthorized.withProblem(Problem("https://httpstatuses.com/401", "no authorization"))

Result will be something like

{
  "type": "https://httpstatuses.com/404",
  "title": "Cannot find requested object",
  "status": 404
}

You can configure URL generation by changing the import import de.lenabrueder.rfc7807.PlayIntegration._ to import de.lenabrueder.rfc7807.PlayIntegration.ResultAsProblem and providing an instance of UrlConfiguration implicitly when calling the withProblem or asProblem functions.

Versions

Version
2.6.1
2.6.0