Skip to content

Commit

Permalink
Add Request struct and process_response/1
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanwinchester committed Oct 8, 2018
1 parent da41878 commit c47b540
Show file tree
Hide file tree
Showing 3 changed files with 432 additions and 97 deletions.
31 changes: 29 additions & 2 deletions lib/httpoison.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
defmodule HTTPoison.Request do
@enforce_keys [:url]
defstruct method: :get, url: nil, headers: [], body: "", params: %{}, options: []
@type method :: :get | :post | :put | :patch | :delete | :options | :head
@type headers :: [{atom, binary}] | [{binary, binary}] | %{binary => binary}
@type url :: binary
@type body :: binary | {:form, [{atom, any}]} | {:file, binary}
@type params :: map | keyword | [{binary, binary}]
@type options :: keyword
@type t :: %__MODULE__{
method: method,
url: binary,
headers: headers,
body: body,
params: params,
options: options
}
end

defmodule HTTPoison.Response do
defstruct status_code: nil, body: nil, headers: [], request_url: nil
@type t :: %__MODULE__{status_code: integer, body: term, headers: list}
defstruct status_code: nil, body: nil, headers: [], request_url: nil, request: nil
alias HTTPoison.Request

@type t :: %__MODULE__{
status_code: integer,
body: term,
headers: list,
request: Request.t(),
request_url: Request.url()
}
end

defmodule HTTPoison.AsyncResponse do
Expand Down
Loading

0 comments on commit c47b540

Please sign in to comment.