akka/akka-http

Ability to use custom MediaTypes with `SprayJsonSupport`

Open

#316 opened on Sep 15, 2016

View on GitHub
 (2 comments) (1 reaction) (0 assignees)Scala (598 forks)batch import
1 - triagedhackathonhelp wantedt:marshalling

Repository metrics

Stars
 (1,311 stars)
PR merge metrics
 (Avg merge 1d 10h) (2 merged PRs in 30d)

Description

The akka-http / Spray json integration is pretty good, but forces one to get generic application/json output. Use of more specific data types (e.g. application/problem+json) is common, and beneficial. However, I did not find a way to implement that with akka-http 2.4.10.

Suggestion: SprayJsonSupport could take an implicit MediaType parameter, defaulting to application/json.

I will make a local copy of the code and experiment with this approach. Decided to first bring this up as an Issue for discussion - can provide a PR if there's acceptance for such a feature.

https://github.com/akka/akka/blob/0ed4a2aae9ecab43ef806025596a5573ddc883ea/akka-http-marshallers-scala/akka-http-spray-json/src/main/scala/akka/http/scaladsl/marshallers/sprayjson/SprayJsonSupport.scala

Contributor guide