:rainbow: Code samples of advanced features of Http4s in combination with some features of Fs2 not often seen.
Code samples of advanced features of Http4s in combination with some features of Fs2 not often seen.
FileServicereading all the directories in your
$HOMEdirectory to the
FileHttpEndpoint.
You'll need two sbt sessions. Run the server in one and after the client in the other to try it out.
Accept Encodingheader to
gzip.
/at the end.
Response compression is verified by
HexNameHttpEndpointSpec. You can also try it out on Postman or similar.
The
TimeoutHttpEndpointgenerates a response in a random time to demonstrate the use.
ChunkAggregatormiddleware to wrap the streaming
FileHttpEndpointand remove the Chunked Transfer Encoding.
The endpoint
/v1/nonstream/dirs?depth=3demonstrates the use case.
The
JsonXmlHttpEndpointdemonstrates this use case and it's validated in its spec.
MultipartHttpEndpointis responsible for parsing multipart data with the given multipart decoder.
Similar to the streaming example, you'll need to run both Server and MultipartClient to see how it works.
NOTE: Beware of the creation of
rick.jpgfile in your HOME directory!
BasicAuthHttpEndpoint.
GitHubHttpEndpoint.
In the fs2 package you'll find some practical examples of the few things it's possible to build with this powerful streaming library. This might serve as a starting point, your creativity will do the rest.
Apart from the use of the three core types
Stream[F, O],
Pipe[F, I, O]and
Sink[F, I]you'll find examples of use of the following types:
Topic[F, A]
Signal[F, A]
Queue[F, A]
Ref[F, A]
Promise[F, A]
Semaphore[F]
In addition to the use of some other functions useful in Parallel and Concurrent scenarios.