Packages
lexdee
2.3.7
2.6.4
2.6.3
2.6.2
2.6.1
2.6.0
2.5.1
2.5.0
2.4.5
2.4.4
2.4.3
2.4.2
2.4.1
2.4.0
2.3.11
2.3.10
2.3.9
2.3.8
2.3.7
2.3.6
2.3.5
2.3.4
2.3.3
2.3.2
2.3.0
2.2.7
2.2.6
2.2.5
2.2.3
2.2.2
2.2.1
2.2.0
2.1.1
2.0.2
2.0.1
2.0.0
1.0.6
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
0.3.3
0.3.2
0.3.1
0.3.0
0.2.5
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
0.1.10
0.1.9
0.1.8
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
Client library for LXD
Current section
Files
Jump to
Current section
Files
lib/lexdee/response.ex
defmodule Lexdee.Response do
@behaviour Tesla.Middleware
def call(env, next, _options) do
env
|> Tesla.run(next)
|> case do
{:ok, %{status: status, body: %{"metadata" => response}} = env}
when status in [200, 201, 202] ->
{:ok, %{env | body: response}}
{:ok, %{status: status} = env} when status in [200] ->
{:ok, env}
{:ok, %{body: response}} ->
{:error, response}
{:error, reason} ->
{:error, reason}
end
end
end