The type of request definitions
Most request definitions have the type Request[T]
. The T
specifies the type to which the response will be read. By default, this is Either[String, String]
. But it can also be e.g. Array[Byte]
or Unit
, if the response should be ignored. Response body handling can be changed by calling the .response
method. With backends which support streaming, this can also be a supported stream type. See response body specifications for more details.
If you’re using streaming request/response bodies, you’ll get a StreamRequest[T, R]
. The R
type parameter specifies the requirements of this request. In case of streaming, this will be an implementation of Streams[S]
, such as Fs2Streams[F]
or PekkoStreams
. You can only send such requests using backends, which also support this type of streaming (this is verified at compile-time)!
If you’re describing a web socket request, you’ll get a WebSocketRequest[F[_], T]
. The F[_]
type parameter describes the effect, using which the web socket is processed (by default, the request then also contains the entire logic to interact with the web socket, although this is not strictly required). For synchronous web sockets, F[_]
will be Identity
(“no wrapper”, direct-style). For asynchronous web sockets, F[_]
might be Future
or IO
(or any other effect type). As with streams, such requests can only be sent using backends which support web sockets, and the effect type used to process the web socket.
Finally, if you’re processing the websocket using streaming, you’ll work with a WebSocketStreamRequest[T, S]
. As before, S
will contain the required streaming capability. However, it will also contain the effect type, which is used to interact with the web socket. An example value for S
might be PekkoStreams & Effect[Future]
.