Barracuda
Is a library that allows generation of HTTP clients in a declarative manner. For example,
defmodule Github do
use Barracuda.Compiler, otp_app: :barracuda
require Logger
call :user_repos,
path: "/users/{:username}/repos",
verb: :get,
required: [:username],
required_headers: ["accept"],
expect: 200
endis github client that will fetch user’s repositories and can be used as so:
Github.user_repos username: "ashneyderman"this client needs additional configuration. Since client is part of :barracuda application, config for it might look like this:
config :barracuda, Github,
base_url: "https://api.github.com"Installation
If available in Hex, the package can be installed as:
-
Add
barracudato your list of dependencies inmix.exs:
```elixir
def deps do
[{:barracuda, "~> 0.1.0"}]
end
```-
Ensure
barracudais started before your application:
```elixir
def application do
[applications: [:barracuda]]
end
```