shuz / go-req

CLI Application for running .http files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

req

CLI Application for running .http files

asciicast

Installation

go install github.com/go-rq/req@latest

Usage

# load all requests in the current directory tree
req

# load all requests from the directory tree at the specified path
req ./path/to/dir

req --help
Usage of req:
  -e string
        path to .env file (shorthand)
  -env string
        path to .env file

.http File Syntax

### <name of request>
< {% <pre-request
javascipt> %} 

<method> <url>
<header>:<value>
...

<request body>

< {% <post-request 
javascript> %}

Scripts

Scripts can be embedded in the .http request directly or loaded from

### <name of request>
< path/to/script.js

<method> <url>
<header>:<value>
...

<request body>

< path/to/script.js

Examples

### Create a User
< {% 
    setEnv('host', 'http://localhost:8000');
    setEnv('name', 'r2d2');
%}
POST {{host}}/users
Content-Type: application/json

{
    "name": "{{name}}"
}

< {% 
    assertTrue(response.status === 200, 'response code is 200');
%}

About

CLI Application for running .http files

License:MIT License


Languages

Language:Go 100.0%