Packages
req
0.8.0-rc.0
0.8.0-rc.0
0.7.3
0.7.2
0.7.1
0.7.0
0.6.3
0.6.2
0.6.1
0.6.0
0.5.18
0.5.17
0.5.16
0.5.15
0.5.14
0.5.13
0.5.12
0.5.11
0.5.10
0.5.9
0.5.8
0.5.7
0.5.6
0.5.5
0.5.4
0.5.3
0.5.2
0.5.1
0.5.0
0.4.14
0.4.13
0.4.12
0.4.11
0.4.10
0.4.9
0.4.8
0.4.7
0.4.6
0.4.5
0.4.4
0.4.3
0.4.2
0.4.1
0.4.0
0.3.12
0.3.11
0.3.10
0.3.9
0.3.8
0.3.7
0.3.6
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.2.2
0.2.1
0.2.0
0.1.2
0.1.1
0.1.0
Req is a batteries-included HTTP client for Elixir.
Current section
Files
Jump to
Current section
Files
mix.exs
defmodule Req.MixProject do
use Mix.Project
@version "0.8.0-rc.0"
@source_url "https://github.com/wojtekmach/req"
def project do
[
app: :req,
version: @version,
elixir: "~> 1.18",
start_permanent: Mix.env() == :prod,
deps: deps(),
package: package(),
docs: docs(),
aliases: aliases(),
elixirc_paths: elixirc_paths(Mix.env()),
elixirc_options: [
no_warn_undefined: [
NimbleCSV.RFC4180,
Plug.Conn,
Plug.HTML,
Plug.Test,
:brotli,
:brotli_encoder,
:brotli_decoder,
:zstd
]
]
]
end
def application do
[
mod: {Req.Application, []},
extra_applications: extra_applications(Mix.env())
]
end
def cli do
[
preferred_envs: [
"test.all": :test,
"test.adapters": :test,
docs: :docs,
"hex.publish": :docs
]
]
end
defp package do
[
description: "Req is a batteries-included HTTP client for Elixir.",
licenses: ["Apache-2.0"],
links: %{
"GitHub" => @source_url,
"Changelog" => "https://hexdocs.pm/req/changelog.html"
}
]
end
defp aliases do
[
docs: [&tmp_extras/1, "docs"],
"test.all": &test_all/1,
"test.adapters": &test_adapters/1
]
end
defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]
defp extra_applications(:test), do: [:logger, :inets]
defp extra_applications(_), do: [:logger]
defp tmp_extras(_args) do
File.mkdir_p!("tmp")
for path <- ["README.md", "CHANGELOG.md"] do
contents =
Regex.replace(
~r|^(\[[^\]]+\]:[ \t]*)https://hexdocs\.pm/req(?:/#{Regex.escape(@version)})?(?:/([A-Z][\w.]*)\.html(?:#(\S+/\d+))?)?$|m,
File.read!(path),
fn _, prefix, mod, fun ->
cond do
fun != "" -> prefix <> "`#{mod}.#{fun}`"
mod != "" -> prefix <> "`#{mod}`"
true -> prefix <> "`Req`"
end
end
)
contents =
Regex.replace(
~r|\[([^\]]+)\]\(https://hexdocs\.pm/req/(?:#{Regex.escape(@version)}/)?([A-Z][\w.]*)\.html#(\S+/\d+)\)|,
contents,
fn _, text, mod, fun -> "[#{text}](`#{mod}.#{fun}`)" end
)
File.write!("tmp/#{path}", contents)
end
end
defp test_all(args) do
test_adapters(["--include", "integration" | args])
end
defp test_adapters(args) do
adapters =
if adapters = System.get_env("REQ_ADAPTERS") do
String.split(adapters, ",")
else
~w(finch httpc mint plug)
end
for adapter <- adapters do
{_, status} =
System.cmd("mix", ["test" | args],
env: [{"REQ_ADAPTER", adapter}],
into: IO.stream(:stdio, :line)
)
if status != 0 do
exit({:shutdown, status})
end
end
end
defp deps do
[
{:finch, "~> 0.21", finch_opts()},
{:mime, "~> 2.0.6 or ~> 2.1"},
{:nimble_csv, "~> 1.0", optional: true},
{:server_sent_events, "~> 1.0"},
{:plug, "~> 1.0", [optional: true] ++ plug_opts()},
{:brotli, "~> 0.3.1", optional: true},
{:aws_signature, "~> 0.3.2", only: :test},
{:bypass, "~> 2.1", only: :test},
{:ex_doc, ">= 0.0.0", only: :docs, warn_if_outdated: true},
{:bandit, "~> 1.0", only: :test}
]
end
defp finch_opts do
cond do
path = System.get_env("FINCH_PATH") ->
[path: path]
ref = System.get_env("FINCH_REF") ->
[github: "sneako/finch", ref: ref]
true ->
[]
end
end
defp plug_opts do
cond do
path = System.get_env("PLUG_PATH") ->
[path: path, override: true]
ref = System.get_env("PLUG_REF") ->
[github: "elixir-plug/plug", ref: ref, override: true]
true ->
[]
end
end
defp docs do
[
main: "readme",
source_url: @source_url,
source_ref: "v#{@version}",
groups_for_docs: [
Types: &(&1[:kind] == :type),
Callbacks: &(&1[:kind] == :callback),
"Request Steps": &(&1[:step] == :request),
Functions: &(&1[:kind] == :function and &1[:type] not in [:request, :mock, :async]),
"Functions (Making Requests)": &(&1[:type] == :request),
"Functions (Async Response)": &(&1[:type] == :async),
"Functions (Mocks & Stubs)": &(&1[:type] == :mock)
],
groups_for_modules: [
Steps: [
Req.Auth,
Req.Checksum,
Req.Decode,
Req.Decompress,
Req.Expect,
Req.Redirect,
Req.Retry,
Req.Steps
],
Adapters: [
Req.Adapter,
Req.Finch,
Req.Plug
],
Formats: [
Req.Brotli,
Req.CSV,
Req.Gzip,
Req.JSON,
Req.NDJSON,
Req.SSE,
Req.Tar,
Req.ZIP,
Req.Zstd
]
],
extras: [
"tmp/README.md",
"tmp/CHANGELOG.md"
],
skip_code_autolink_to: [
"Req.Request.halt/2",
"Req.Request.run_request/1",
"Req.Test.stub/1",
"Req.Utils.aws_sigv4_url/1",
"Req.update/2"
]
]
end
def legacy_headers_as_lists? do
Application.get_env(:req, :legacy_headers_as_lists, false)
end
end