maxwell v2.2.2 Maxwell
The maxwell specification.
There are two kind of usages: basic usage and advanced middleware usage.
Basic Usage
## Returns Origin IP, for example %{"origin" => "127.0.0.1"}
"http://httpbin.org/ip"
|> Maxwell.Conn.new()
|> Maxwell.get!()
|> Maxwell.Conn.get_resp_body()
|> Poison.decode!()
Find all get_*&put_*
helper functions by h Maxwell.Conn.xxx
Advanced Middleware Usage(Create API Client).
defmodule Client do
use Maxwell.Builder, ~w(get)a
adapter Maxwell.Adapter.Ibrowse
middleware Maxwell.Middleware.BaseUrl, "http://httpbin.org"
middleware Maxwell.Middleware.Opts, [connect_timeout: 5000]
middleware Maxwell.Middleware.Headers, %{"User-Agent" => "zhongwencool"}
middleware Maxwell.Middleware.Json
## Returns origin IP, for example "127.0.0.1"
def ip() do
"/ip"
|> new()
|> get!()
|> get_resp_body("origin")
end
## Generates n random bytes of binary data, accepts optional seed integer parameter
def get_random_bytes(size) do
"/bytes/#{size}"
|> new()
|> get!()
|> get_resp_body(&to_string/1)
end
end
Summary
Functions
DELETE http method without request body
DELETE! http method without request body
DELETE! http method without request body
GET http method without request body
GET! http method without request body
GET! http method without request body
HEAD http method without request body
HEAD! http method without request body
HEAD! http method without request body
OPTIONS http method without request body
OPTIONS! http method without request body
OPTIONS! http method without request body
PATCH method
PATCH! http method
PATCH! http method
POST method
POST! http method
POST! http method
PUT method
PUT! http method
PUT! http method
TRACE http method without request body
TRACE! http method without request body
TRACE! http method without request body
Functions
DELETE http method without request body.
conn
-%Maxwell.Conn{}
Returns {:ok, %Maxwell.Conn{}}
or {:error, reason_term, %Maxwell.Conn{}}
.
DELETE! http method without request body.
conn
- seedelete/1
Returns %Maxwell.Conn{}
or raise %MaxWell.Error{}
when status not in [200..299].
DELETE! http method without request body.
conn
- seedelete/1
normal_statuses
- the specified status which not raise exception, for example: [200, 201]
Returns %Maxwell.Conn{}
or raise %MaxWell.Error{}
.
GET http method without request body.
conn
-%Maxwell.Conn{}
Returns {:ok, %Maxwell.Conn{}}
or {:error, reason_term, %Maxwell.Conn{}}
.
GET! http method without request body.
conn
- seeget/1
Returns %Maxwell.Conn{}
or raise %MaxWell.Error{}
when status not in [200..299].
GET! http method without request body.
conn
- seeget/1
normal_statuses
- the specified status which not raise exception, for example: [200, 201]
Returns %Maxwell.Conn{}
or raise %MaxWell.Error{}
.
HEAD http method without request body.
conn
-%Maxwell.Conn{}
Returns {:ok, %Maxwell.Conn{}}
or {:error, reason_term, %Maxwell.Conn{}}
.
HEAD! http method without request body.
conn
- seehead/1
Returns %Maxwell.Conn{}
or raise %MaxWell.Error{}
when status not in [200..299].
HEAD! http method without request body.
conn
- seehead/1
normal_statuses
- the specified status which not raise exception, for example: [200, 201]
Returns %Maxwell.Conn{}
or raise %MaxWell.Error{}
.
OPTIONS http method without request body.
conn
-%Maxwell.Conn{}
Returns {:ok, %Maxwell.Conn{}}
or {:error, reason_term, %Maxwell.Conn{}}
.
OPTIONS! http method without request body.
conn
- seeoptions/1
Returns %Maxwell.Conn{}
or raise %MaxWell.Error{}
when status not in [200..299].
OPTIONS! http method without request body.
conn
- seeoptions/1
normal_statuses
- the specified status which not raise exception, for example: [200, 201]
Returns %Maxwell.Conn{}
or raise %MaxWell.Error{}
.
PATCH method.
conn
-%Maxwell.Conn{}
.
Returns {:ok, %Maxwell.Conn{}}
or {:error, reason, %Maxwell.Conn{}}
PATCH! http method.
conn
- seepatch/1
Return %Maxwell.Conn{}
or raise %Maxwell.Error{}
when status not in [200.299]
PATCH! http method.
conn
- seepatch/1
normal_statuses
- the specified status which not raise exception, for example: [200, 201]
Returns %Maxwell.Conn{}
or raise %MaxWell.Error{}
.
POST method.
conn
-%Maxwell.Conn{}
.
Returns {:ok, %Maxwell.Conn{}}
or {:error, reason, %Maxwell.Conn{}}
POST! http method.
conn
- seepost/1
Return %Maxwell.Conn{}
or raise %Maxwell.Error{}
when status not in [200.299]
POST! http method.
conn
- seepost/1
normal_statuses
- the specified status which not raise exception, for example: [200, 201]
Returns %Maxwell.Conn{}
or raise %MaxWell.Error{}
.
PUT method.
conn
-%Maxwell.Conn{}
.
Returns {:ok, %Maxwell.Conn{}}
or {:error, reason, %Maxwell.Conn{}}
PUT! http method.
conn
- seeput/1
Return %Maxwell.Conn{}
or raise %Maxwell.Error{}
when status not in [200.299]
PUT! http method.
conn
- seeput/1
normal_statuses
- the specified status which not raise exception, for example: [200, 201]
Returns %Maxwell.Conn{}
or raise %MaxWell.Error{}
.
TRACE http method without request body.
conn
-%Maxwell.Conn{}
Returns {:ok, %Maxwell.Conn{}}
or {:error, reason_term, %Maxwell.Conn{}}
.
TRACE! http method without request body.
conn
- seetrace/1
Returns %Maxwell.Conn{}
or raise %MaxWell.Error{}
when status not in [200..299].
TRACE! http method without request body.
conn
- seetrace/1
normal_statuses
- the specified status which not raise exception, for example: [200, 201]
Returns %Maxwell.Conn{}
or raise %MaxWell.Error{}
.