akka/akka-http

Add a marshalling example to "HttpRequest and HttpResponse / Processing responses" documentation

Open

#2.842 aberto em 1 de dez. de 2019

Ver no GitHub
 (1 comment) (1 reaction) (0 assignees)Scala (598 forks)batch import
1 - triagedhackathonhelp wantedt:clientt:docst:marshalling

Métricas do repositório

Stars
 (1.311 stars)
Métricas de merge de PR
 (Mesclagem média 1d 10h) (2 fundiu PRs em 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.

Guia do colaborador