A Reactor DSL extension for making HTTP requests with Req.
Find a file
Renovate Bot af2ce793c6
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
chore(deps): update dependency spark to v2.2.29
2024-09-16 12:07:10 +12:00
config chore: prepare for initial release. 2024-08-13 17:04:49 +12:00
documentation/dsls chore: prepare for initial release. 2024-08-13 17:04:49 +12:00
lib improvement: Add igniter installer. (#8) 2024-08-14 13:48:26 +12:00
test chore: prepare for initial release. 2024-08-13 17:04:49 +12:00
.drone.yml chore: prepare for initial release. 2024-08-13 17:04:49 +12:00
.formatter.exs chore: prepare for initial release. 2024-08-13 17:04:49 +12:00
.gitignore chore: prepare for initial release. 2024-08-13 17:04:49 +12:00
.tool-versions chore: prepare for initial release. 2024-08-13 17:04:49 +12:00
CHANGELOG.md chore: release version v0.1.1 2024-08-14 01:49:01 +00:00
LICENSE.md chore: prepare for initial release. 2024-08-13 17:04:49 +12:00
mix.exs chore(deps): update dependency reactor to ~> 0.10 2024-09-16 11:06:34 +12:00
mix.lock chore(deps): update dependency spark to v2.2.29 2024-09-16 12:07:10 +12:00
README.md chore: release version v0.1.1 2024-08-14 01:49:01 +00:00
renovate.json chore: Configure Renovate (#1) 2024-08-13 17:20:31 +12:00

Reactor.Req

Build Status Hex.pm Hippocratic License HL3-FULL

A Reactor extension that provides steps for working with HTTP requests via Req.

Example

The following example uses Reactor to retrieve the repository description from the Forgejo API:

defmodule GetForgejoRepoDescription do
  use Reactor, extensions: [Reactor.Req]

  input :hostname
  input :owner
  input :repo

  step :repo_url do
    argument :hostname, input(:hostname)
    argument :owner, input(:owner)
    argument :repo, input(:repo)

    run fn args ->
      URI.new("https://#{args.hostname}/api/v1/repos/#{args.owner}/#{args.repo}")
    end
  end

  req_get :get_repo do
    url result(:repo_url)
    headers value([accept: "application/json"])
    http_errors value(:raise)
  end

  step :get_description do
    argument :description, result(:get_repo, [:body, "description"])
    run fn args -> {:ok, args.description} end
  end
end

Reactor.run!(GetForgejoRepoDescription, %{
  hostname: "harton.dev",
  owner: "james",
  repo: "reactor_req"
})

# => "A Reactor DSL extension for making HTTP requests with Req."

Installation

If available in Hex, the package can be installed by adding reactor_req to your list of dependencies in mix.exs:

def deps do
  [
    {:reactor_req, "~> 0.1.1"}
  ]
end

Documentation for the latest release is available on HexDocs.

Github Mirror

This repository is mirrored on Github from it's primary location on my Forgejo instance. Feel free to raise issues and open PRs on Github.

License

This software is licensed under the terms of the HL3-FULL, see the LICENSE.md file included with this package for the terms.

This license actively proscribes this software being used by and for some industries, countries and activities. If your usage of this software doesn't comply with the terms of this license, then contact me with the details of your use-case to organise the purchase of a license - the cost of which may include a donation to a suitable charity or NGO.