Skip to content

FollowTheProcess/req

Repository files navigation

req

License Go Report Card GitHub CI codecov

Execute .http files from the command line

Warning

req is in early development and is not yet ready for use

caution

Project Description

req is a command line toolkit to execute .http files

// Comments can begin with slashes '/' or hashes '#' and last until the next newline character '\n'
# This is also a comment (I'll use '/' from now on but you are free to use both)

// Global variables (e.g. base url) can be defined with '@ident = <value>'
@base = https://api.company.com

// 3 '#' in a row mark a new HTTP request, with an optional name e.g. 'Delete employee 1'
### [name]
HTTP_METHOD <url>
Header-Name: <header value>

// You can also give them names like this, although names like this
// do not allow spaces e.g. 'Delete employee 1' must be 'DeleteEmployee1'
###
# @name <name>
# @name=<name>
# @name = <name>
HTTP_METHOD <url>
...

// Global variables are interpolated like this
### Get employee 1
GET {{base}}/employees/1

// Pass the body of requests like this
### Update employee 1 name
PATCH {{base}}/employees/1
Content-Type: application/json

{
  "name": "Namey McNamerson"
}

See the Spec and Syntax Guide for more info.

Note

The custom javascript portions (e.g. the {% ... %} blocks) of the spec are not implemented as these are editor specific and require a javascript runtime.

Installation

Compiled binaries for all supported platforms can be found in the GitHub release. There is also a homebrew tap:

brew install FollowTheProcess/tap/req

Quickstart

Given a .http file containing http requests like this:

// demo.http

@base = https://localhost:5167
 
### Create a new item
POST {{base}}/todoitems
Content-Type: application/json
 
{
  "id": "{{ $guid }}",
  "name":"walk dog",
  "isComplete":false
}
 
### Get All items
GET {{base}}/todoitems
 
### Update item
PUT {{base}}/todoitems/1
Content-Type: application/json
 
{
  "id": 1,
  "name":"walk dog",
  "isComplete": true
}
 
### Delete item
DELETE {{base}}/todoitems/1

You can invoke any one of them, like this...

req do ./demo.http --request "Get All items"

Credits

This package was created with copier and the FollowTheProcess/go_copier project template.

About

Work with .http files on the command line

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages