File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,24 @@ Mawell is an HTTP client that provides a common interface over many adapters (su
77
88It borrow idea from [ tesla(elixir)] ( https://github.com/teamon/tesla ) which losely base on [ Faraday(ruby)] ( https://github.com/lostisland/faraday )
99
10+ We already have httpoison and httpotion, why we need another wrapper?
11+
12+ I am trouble with define a lot of ` process_url/1 ` ` process_request_headers ` ` process_response_body ` functions,
13+
14+ but those functions almost the same in most cases, we don't need define then every time.
15+
16+ the same operation steps:
17+
18+ 1 . Put query and url encode together;
19+ 2 . Add headers
20+ 3 . Add body
21+ 4 . Need encode request body with json or multipart
22+ 5 . Accord reponse's header to decode response body by self
23+
24+ So Maxwell make those same steps into middlewares, it don't lose any flexible.
25+
26+ [ See the specific example here] ( https://gist.github.com/zhongwencool/6cd44df1acd699fc9c7159882ef3b597 ) .
27+
1028## Usage
1129
1230Use ` Maxwell.Builder ` module to create API wrappers.
Original file line number Diff line number Diff line change @@ -55,4 +55,6 @@ defmodule Maxwell do
5555 opts: [ ] ,
5656 status: nil
5757
58+ use Maxwell.Builder
59+
5860end
Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ defmodule MiddlewareTest do
125125 use ExUnit.Case
126126
127127 defmodule Client do
128- use Maxwell.Builder , ~w ( get post)
128+ use Maxwell.Builder , [ " get" , " post" ]
129129
130130 middleware Maxwell.Middleware.BaseUrl , "http://example.com"
131131 middleware Maxwell.Middleware.Opts , [ connect_timeout: 3000 ]
You can’t perform that action at this time.
0 commit comments