akka/akka-http
View on GitHubAdd a marshalling example to "HttpRequest and HttpResponse / Processing responses" documentation
Open
#2,842 opened on Dec 1, 2019
1 - triagedhackathonhelp wantedt:clientt:docst:marshalling
Repository metrics
- Stars
- (1,311 stars)
- PR merge metrics
- (Avg merge 1d 10h) (2 merged PRs in 30d)
Description
In the documentation page on creating HTTP requests with akka-http client functionality, it would be extremely valuable if there was an example on how to include a marshalable object as a request entity. E.g.
import akka.http.scaladsl.unmarshalling.Unmarshal
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import spray.json.DefaultJsonProtocol._
import akka.http.scaladsl.marshalling.Marshal
case class Pet(name: String)
implicit val petFormat = jsonFormat1(Pet)
for {
entity <- Marshal[Pet("Mamon").to[RequestEntity]
request <- HttpRequest(
method = HttpMethods.POST,
uri = "https://userservice.example/users",
entity = entity
)
} yield request
I have not made a pull request for this as I wouldn't be able to provide a Java version anyway.
There is a documentation page about using marshallers, but it would be very handy to have those two pieces of information presented together.