Skip to content

jonathanlloyd/rif

Repository files navigation

RIF logo

Build Status Go Report Card GPL3 Licensed Download count

Website  |  Documentation  |  Download


Keep your Requests In Files.

RIF is a command-line tool that allows you to store repetitive and complex HTTP requests as files to make testing and interacting with HTTP APIs a breeze.

Quickstart

Making Your First Request

To get started, we will be making a simple GET request to httpbin.org/get. This endpoint returns the details of GET requests back to the client as JSON.

We will be passing in a URL parameter called message that is parameterised using RIFs variable templating feature.

Open your editor of choice and save the following file to your computer as gethttpbin.rif:

rif_version: 0
url: "http://httpbin.org/get?message=hello%20$(place)"
method: "GET"
variables:
  place:
    type: "string"
    default: "world"

Next, open your terminal in the same location and run RIF, passing in the file you just created:

$ rif ./gethttpbin.rif

If all goes well you should see something like the following:

{
  "args": {
    "message": "hello world"
  }, 
  "headers": {
    "Accept-Encoding": "gzip", 
    "Connection": "close", 
    "Host": "httpbin.org", 
    "User-Agent": "RIF/0.2.0"
  }, 
  "origin": "<YOUR IP ADDRESS>", 
  "url": "http://httpbin.org/get?message=hello world"
}

Variable Templating

Now let's use RIF's variable templating feature to override our welcome message. Paste the following command into your terminal:

$ rif ./gethttpbin.rif place=universe

You should now see that the response has changed:

{
  "args": {
    "message": "hello universe"
  }, 
  "headers": {
    "Accept-Encoding": "gzip", 
    "Connection": "close", 
    "Host": "httpbin.org", 
    "User-Agent": "RIF/0.2.0"
  }, 
  "origin": "<YOUR IP ADDRESS>", 
  "url": "http://httpbin.org/get?message=hello universe"
}

Congratulations! You have just made and executed your first .rif file!

Installation

Quick Install/Upgrade

MacOS (64bit)

To install/upgrade RIF on MacOS use the RIF brew tap:

brew install jonathanlloyd/rif/rif

Linux (64bit)

To install/upgrade RIF on a standard 64bit linux install, run the following in your shell:

curl -Lo rif.tar $(curl https://api.github.com/repos/jonathanlloyd/rif/releases/latest 2>/dev/null | grep -o http[^[:space:]]*linux_amd64\.tar\.gz) 2>/dev/null && tar -xf rif.tar rif && chmod +x rif && sudo mv rif /usr/local/bin/rif && rm ./rif.tar && rif --help && rif --version

Verifying Your Installation

To verify that you have installed RIF correctly, run the following command in your terminal:

$ rif --version

If RIF is correctly installed you should see the version and build number printed to the screen:

Version: <expected version number>
Build: <build number>

Manual Install (other platforms)

RIF is distributed as a single binary executable. To install it all you need to do is download the correct binary from the downloads page and put it somewhere in your path.

Supported Platforms

macOS

Download

  • If you are running a 64bit system:
    • rif_<version>_darwin_amd64.tar.gz
  • If you are running a 32bit system:
    • rif_<version>_darwin_386.tar.gz

Path

Extract the appropriate binary and add it to a directory in your path. We recommend that you put it in /user/local.

Linux

Download

  • If you are running a 64bit system:
    • rif_<version>_linux_amd64.tar.gz
  • If you are running a 32bit system:
    • rif_<version>_linux_386.tar.gz

Path

Extract the appropriate binary and add it to a directory in your path. We recommend that you put it in /usr/local/bin.

Windows

Download

  • If you are running a 64bit system:
    • rif_<version>_windows_amd64.tar.gz
  • If you are running a 32bit system:
    • rif_<version>_windows_386.tar.gz

Path

Extract the appropriate binary and add it to a directory in your path. We recommend that you put it in c:\RIF and add this directory to your path.