There’s no time like the present to jump into Elixir and start to explore it more. That’s the functional language that’s taking the programming world very fast. Today we are going to present you a new experimental library that was just released. Meet Mint, a new HTTP client for Elixir.
Mint is a new low-level HTTP client that aims to provide a small and functional core that others can build on top. Mint is connection based: each connection is a single struct with an associated socket belonging to the process that started the connection. Since no extra processes are started for the connection, you can choose the process architecture that better fits your application.
With Mint each connection has a single immutable data structure that the user needs to manage. Mint uses “active mode” sockets. This means data and events from the socket are sent as messages to the process that started the connection. The user passes the messages to the
stream/2 function that returns the updated connection and a list of “responses”. Responses are streamed back which means you won’t receive a single full HTTP response back from
stream/2, instead the response is returned in partial response chunks. A chunk can be the status line, HTTP headers, or part of the response body.
The first version of Mint has just been released. It is an experimental library trying a new approach to building HTTP libraries so don’t expect a fully stable API yet. Use Mint to explore new ideas for HTTP connection management and building higher-level clients on top of Mint. In the future connection pooling and a higher level API may be added to supplement the current low-level API, either directly to Mint or via different libraries.
Find more about Mint here.
And do you know what are Protocols in Elixir? You are lucky to learn that from our blog.