Skip to content

agleb/jrac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jrac

Hex.pm

Jrac - JSON RESTful API client.

Jrac is a boilerplate for writing RESTful API consuming apps.

Methods: GET, POST, PUT, PATCH, DELETE

Note that Jrac does not support JSON API spec.

Jrac was made to consume simple RESTful APIs with JSON-encoded output. The header "application/json" will be send to inform the API that.

Jrac is adaptive - you can override all methods as and when needed.

Installation

Add jrac to your list of dependencies in mix.exs:

def deps do
  [
    {:jrac, "~> 0.1.0"}
  ]
end

Add API base url to config

config :jrac, base_url_key: "https://reqres.in/api"

Usage

# Set the URL for your API, set headers to be sent with each request
  use Jrac.Behaviour,
    app_name: :jrac,
    base_url_key_name: :base_url_key,
    headers: [{"Accept", "application/json"}]

case do_get_single("users", 4) do
  {:ok, user} -> user
  {:error, description} -> {:error, description}
  {:error, {:status_code, 404}} -> :not_found
  {:error, {:status_code, 500}} -> :shipwreck
end

...

License

MIT.

About

Elixir JSON RESTful API client

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages