Mint, a new HTTP library for Elixir
elixir-lang.org
elixir-lang.org
For Elixir devs who want a higher-level interface to Mint, check out Mojito: https://hexdocs.pm/mojito/Mojito.html https://github.com/appcues/mojito
It builds on Mint to offer one-off requests, connection pooling, and a generally friendlier interface than playing telephone with a TCP socket. :) Play around and let me know how it goes!
Mint looks lower level, but with a clean, well-documented API which should be a great building block in the future. Congrats Eric and Andrea!
(EDIT: I had accidentally written "latter" instead of "former" above, causing a bunch of people to correct me, thanks for that)
Presumably this is because HTTP2 is sort of two protocol layers stuck together—a session layer and an application layer—and at the session layer, HTTP2 just has identical "peers" rather than any concept of client/server. (Theoretically either side of an HTTP2 connection could open a session to the other side and send a message! It's just the semantics of the HTTP-mimicking application layer that stop this. If you read the RFC, all the session stuff—frames et al—are specified in terms of "peers", and it's only when the spec starts talking about HTTP request-response that we see "clients" and "servers" mentioned.)
Since implementing the session layer is most of the work of implementing an HTTP2 client/server, and the session layer is just about "peers", once you've implemented it for a client (or server), you can reuse it to implement a server (or client) mostly "for free."
And thank god, HTTPS support built in... it never ceases to amaze me why some HTTP libs don't have TLS as a given.
Separation of concerns. TLS termination is something that can be done separately, and at scale you want to separate it anyway.
I'd like to see some kind of generic HTTP contract or REST-API client builder library next so we can have swappable HTTP adapters (e.g. Mint/Hackney). I don't want to depend on a library like HTTPoison or Tesla directly when making a client, instead just generic Request/Response structs or protocols. That way an internal project can use a single HTTP adapter across all REST integrations rather than whatever the library author chose to use.
I’m interested in this for some of the uglier API integrations I maintain where an ordered chain of requests must be made with no guarantee of delivery and responses that involve a considerable amount of in-memory processing (large XML bodies to be exact). Having control over my process architecture is preferable to leaving it up to the HTTP library’s connection pool in these cases.
I'm excited to try out this library (or something built on top of it)! In my day to day work I use hackney, it's an awesome lib, but sometimes I struggle with documentation.
"Mint, a new HTTP client for Elixir"
In unrelated news, be sure to check out my new project Asbhrjfuugwxcgxedzkyhbwf!
On Google, the first two results for me on "mint elixir":
Mint, a new HTTP library for Elixir - Elixir https://elixir-lang.org/blog/2019/02/25/mint-a-new-http-libr... 42 mins ago - Mint is a new low-level HTTP library that aims to provide a small and functional core that others can build on top.
GitHub - ericmj/mint: Functional HTTP client for Elixir with support for ... https://github.com/ericmj/mint Functional HTTP client for Elixir with support for HTTP/1 and HTTP/2 - ericmj/mint.