All Projects β†’ appcues β†’ Mojito

appcues / Mojito

Licence: mit
An easy-to-use Elixir HTTP client, built on the low-level Mint library.

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to Mojito

Kurly
kurly is an alternative to the widely popular curl program, written in Golang.
Stars: ✭ 319 (-4.2%)
Mutual labels:  http-client, https
Got
🌐 Human-friendly and powerful HTTP request library for Node.js
Stars: ✭ 10,620 (+3089.19%)
Mutual labels:  http-client, https
Esp Request
This project is no longer supported, please use
Stars: ✭ 65 (-80.48%)
Mutual labels:  http-client, https
Gun
HTTP/1.1, HTTP/2 and Websocket client for Erlang/OTP.
Stars: ✭ 710 (+113.21%)
Mutual labels:  http-client, https
restler
Restler is a beautiful and powerful Android app for quickly testing REST API anywhere and anytime.
Stars: ✭ 120 (-63.96%)
Mutual labels:  https, http-client
Xmnetworking
A lightweight but powerful network library with simplified and expressive syntax based on AFNetworking.
Stars: ✭ 980 (+194.29%)
Mutual labels:  http-client, https
Piaf
Client library for HTTP/1.X / HTTP/2 written entirely in OCaml.
Stars: ✭ 86 (-74.17%)
Mutual labels:  http-client, https
Phin
Node HTTP client
Stars: ✭ 449 (+34.83%)
Mutual labels:  http-client, https
Crest
HTTP and REST client for Crystal
Stars: ✭ 174 (-47.75%)
Mutual labels:  http-client, https
Libhv
πŸ”₯ ζ―”libevent、libuvζ›΄ζ˜“η”¨ηš„ε›½δΊ§η½‘η»œεΊ“γ€‚A c/c++ network library for developing TCP/UDP/SSL/HTTP/WebSocket client/server.
Stars: ✭ 3,355 (+907.51%)
Mutual labels:  http-client, https
Fast Android Networking
πŸš€ A Complete Fast Android Networking Library that also supports HTTP/2 πŸš€
Stars: ✭ 5,346 (+1505.41%)
Mutual labels:  http-client, https
electron-request
Zero-dependency, Lightweight HTTP request client for Electron or Node.js
Stars: ✭ 45 (-86.49%)
Mutual labels:  https, http-client
Http Client
Async HTTP/1.1+2 client for PHP based on Amp.
Stars: ✭ 553 (+66.07%)
Mutual labels:  http-client, https
Netty Http Client
An asynchronous http client in Java, with a clean, callback-based API, using Netty 4.x
Stars: ✭ 295 (-11.41%)
Mutual labels:  http-client, https
Http
Event-driven, streaming HTTP client and server implementation for ReactPHP.
Stars: ✭ 507 (+52.25%)
Mutual labels:  http-client, https
Http Client
A high-performance, high-stability, cross-platform HTTP client.
Stars: ✭ 86 (-74.17%)
Mutual labels:  http-client, https
Isahc
The practical HTTP client that is fun to use.
Stars: ✭ 338 (+1.5%)
Mutual labels:  http-client, https
Httpdirfs
A filesystem which allows you to mount HTTP directory listings, with a permanent cache. Now with Airsonic / Subsonic support!
Stars: ✭ 443 (+33.03%)
Mutual labels:  http-client, https
Httpp
Micro http server and client written in C++
Stars: ✭ 144 (-56.76%)
Mutual labels:  http-client, https
http-requests
An HTTP client abstraction that provides a common interface to several different client implementations.
Stars: ✭ 22 (-93.39%)
Mutual labels:  https, http-client

Mojito Build Status Docs Hex.pm Version

Mojito is an easy-to-use, high-performance HTTP client built using the low-level Mint library.

Mojito is built for comfort and for speed. Behind a simple and predictable interface, there is a sophisticated connection pool manager that delivers maximum throughput with no intervention from the user.

Just want to make one request and bail? No problem. Mojito can make one-off requests as well, using the same process-less architecture as Mint.

Quickstart

{:ok, response} = Mojito.request(method: :get, url: "https://github.com")

Why Mojito?

Mojito addresses the following design goals:

  • Little or no configuration needed. Use Mojito to make requests to as many different destinations as you like, without thinking about starting or selecting connection pools. Other clients like Hackney (and HTTPoison), Ibrowse (and HTTPotion), and Erlang's built-in httpc offer this feature, except that...

  • Connection pools should be used only for a single destination. Using a pool for making requests against multiple destinations is less than ideal, as many of the connections need to be reset before use. Mojito assigns requests to the correct pools transparently to the user. Other clients, such as Buoy, Hackney/ HTTPoison, Ibrowse/HTTPotion, etc. force the user to handle this themselves, which is often inconvenient if the full set of HTTP destinations is not known at compile time.

  • Redundant pools to reduce GenServer-related bottlenecks. Mojito can serve requests to the same destination from more than one connection pool, and those pools can be selected by round-robin at runtime in order to minimize resource contention in the Erlang VM. This feature is unique to Mojito.

Installation

Add mojito to your deps in mix.exs:

{:mojito, "~> 0.7.7"}

Configuration

The following config.exs config parameters are supported:

  • :timeout (milliseconds, default 5000) -- Default request timeout.
  • :max_body_size - Max body size in bytes. Defaults to nil in which case no max size will be enforced.
  • :transport_opts (t:Keyword.t, default []) -- Options to pass to the :gen_tcp or :ssl modules. Commonly used to make HTTPS requests with self-signed TLS server certificates; see below for details.
  • :pool_opts (t:pool_opts, default []) -- Configuration options for connection pools.

The following :pool_opts options are supported:

  • :size (integer) sets the number of steady-state connections per pool. Default is 5.
  • :max_overflow (integer) sets the number of additional connections per pool, opened under conditions of heavy load. Default is 10.
  • :pools (integer) sets the maximum number of pools to open for a single destination host and port (not the maximum number of total pools to open). Default is 5.
  • :strategy is either :lifo or :fifo, and selects which connection should be checked out of a single pool. Default is :lifo.
  • :destinations (keyword list of t:pool_opts) allows these parameters to be set for individual :"host:port" destinations.

For example:

use Mix.Config

config :mojito,
  timeout: 2500,
  pool_opts: [
    size: 10,
    destinations: [
      "example.com:443": [
        size: 20,
        max_overflow: 20,
        pools: 10
      ]
    ]
  ]

Certain configs can be overridden with each request. See request/1.

Usage

Make requests with Mojito.request/1 or Mojito.request/5:

>>>> Mojito.request(:get, "https://jsonplaceholder.typicode.com/posts/1")
## or...
>>>> Mojito.request(%{method: :get, url: "https://jsonplaceholder.typicode.com/posts/1"})
## or...
>>>> Mojito.request(method: :get, url: "https://jsonplaceholder.typicode.com/posts/1")

{:ok,
 %Mojito.Response{
   body: "{\n  \"userId\": 1,\n  \"id\": 1,\n  \"title\": \"sunt aut facere repellat provident occaecati excepturi optio reprehenderit\",\n  \"body\": \"quia et suscipit\\nsuscipit recusandae consequuntur expedita et cum\\nreprehenderit molestiae ut ut quas totam\\nnostrum rerum est autem sunt rem eveniet architecto\"\n}",
   headers: [
     {"content-type", "application/json; charset=utf-8"},
     {"content-length", "292"},
     {"connection", "keep-alive"},
     ...
   ],
   status_code: 200
 }}

By default, Mojito will use a connection pool for requests, automatically handling the creation and reuse of pools. If this is not desired, specify the pool: false option with a request to perform a one-off request. See the documentation for request/1 for more details.

Self-signed SSL/TLS certificates

To accept self-signed certificates in HTTPS connections, you can give the transport_opts: [verify: :verify_none] option to Mojito.request or Mojito.Pool.request:

>>>> Mojito.request(method: :get, url: "https://localhost:8443/")
{:error, {:tls_alert, 'bad certificate'}}

>>>> Mojito.request(method: :get, url: "https://localhost:8443/", opts: [transport_opts: [verify: :verify_none]])
{:ok, %Mojito.Response{ ... }}

Telemetry

Mojito integrates with the standard Telemetry library.

See the Mojito.Telemetry module for more information.

Changelog

See the CHANGELOG.md.

Contributing

Thanks for considering contributing to this project, and to the free software ecosystem at large!

Interested in contributing a bug report? Terrific! Please open a GitHub issue and include as much detail as you can. If you have a solution, even better -- please open a pull request with a clear description and tests.

Have a feature idea? Excellent! Please open a GitHub issue for discussion.

Want to implement an issue that's been discussed? Fantastic! Please open a GitHub pull request and write a clear description of the patch. We'll merge your PR a lot sooner if it is well-documented and fully tested.

Contributors and contributions are listed in the changelog. Heartfelt thanks to everyone who's helped make Mojito better.

Authorship and License

Copyright 2018-2021, Appcues, Inc.

This software is released under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].