Coder Social home page Coder Social logo

fire's Introduction

fire

A HTTP request client for your terminal

Usage

Execute a request

fire my_request.yml

Execute a request for a specific environment

fire my_request.yml -e environment

Request Files

A request file uses YAML (.yml) syntax and contains the following properties

Property Required Example Value
method Yes POST
url Yes https://42x.io/some-endpoint
headers No content-type: application/json
body No { "foo": "bar" }
# This is a comment that can be used as a description for the request file
method: POST
url: https://42x.io/some-endpoint
headers:
  accept: application/json
  # Headers `host`, `content-length` (if there is a body) and `user-agent` are always sent
  # since a lot of requests will fail without them.
  content-type: application/json
  x-correlation-id: ce19f5b6-6333-4004-a191-67476fe241be

body: |
  {
    "foo": "bar",
    "nice_primes": [977, 3457, 3457, 6133, 7919]
  }

A more complex example with templating (using Handlebars syntax)

method: GET
url: https://{{DOMAIN_NAME}}/some-endpoint?user={{USER}}
headers:
  accept: application/json
  authorization: Bearer {{TOKEN}}

See examples directory for more examples of how to structure request files.

Templating and Variable Substitution

Request files supports templating where variables can be substituted at execution time. This makes it very easy to have request files that can be re-used for different environments or contexts. Variables can be read from the following sources (from least priority to highest priority):

  1. Environment variables - environment variables in your system are accessed by the application and will be used, but only as last resort if they cannot be found anywhere else
  2. Global environment files - any file named exactly .env or .sec which is present in the same directory or parent directories of the request file
  3. Environment specific files - any file matching the specific environment (like development.env or development.sec if the environment is development) which is present in the same directory or parent directories of the request file, when an environment is specified (using flag -e)
  4. Command line arguments - variables supplied to the application at the command line at execution time (using flag -E), these will override any of the previous sources for variables

The priority of resolved environment files are such as that the any environment file in the same folder as the request file has the highest priority when resolving variables (if the same variable is defined in multiple places). Found files in parent directories will be considered as well, but the futher up they are found the lower priority they will have. If the request files are stored in a Git repository, the application will never consider files outside the repository. If the request is not stored in a Git repository, only the immediate directory and no parents will be considered.

It is possible to specify multiple environments with the --environment (-e) flag, if needed. The order in which the different environments variables are applied are undefined, so it is recommended that you do not have the same variable defined in multiple environments if you are going to use them at the same time.

Note that there is technically not any difference between files ending with .env and .sec. Having two different file endings for environment configuration allows you to have the convention of putting sensitive variables in .sec files while having non-sensitive configuration in .env files. It is highly recommended that you add a .gitignore filter to your repository which is *.sec, so you do not accidentally commit any secrets.

Example of file which contains "environment variables"

API_URL=https://url-to-some.api.com/api
REGION=europe
USERNAME="quoted-username"

Additional Documentation

See fire --help for more documentation on how to use the application.

Building

  1. Install Rust - if you do not have it installed
  2. Clone this repository - git clone [email protected]:mantono/fire.git
  3. Build application - cargo build --release inside the root of the repository
  4. Install application - cargo install --path .

fire's People

Contributors

mantono avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.