Skip to content

1buran/rHttp

Repository files navigation

rHttp - REPL for HTTP

codecov goreportcard Main demo

Color themes (all used colors and emojis are configurable)

Light theme

Responses with minified JSON

JSON min

Edit JSON request payload

Edit JSON Payload

Load JSON request payload from file

Attach file

Load session

Load session

Redirects

Redirects

Introduction

This is project was created when I needed something like REPL for http request in terminal, there are many great tools exist: Postman, Insomnia, httpie, curl etc but i wanted something little bit different, something lightweight, simple and fast, something like REPL when I can quickly modify request, send it and see the response with all the details. I wanted such utility with minimal magic, ideally without any black magic under the hood.

The project has no ambitious goals. It is not killer of Postman or httpie or curl. I hope you may find it useful.

Features

Currently implemented:

  • https, http/2 support
  • Auto following the redirects
  • Easy manipulation of request cookies, headers, params (query string) and form values
  • Easy manipulation of JSON request payload (through the built-in mini editor)
  • Load JSON request payload from file
  • Automatic syntax highlighting of the body of http responses
  • Auto format JSON responses (useful for inspection of minified responses)
  • Save & load sessions (useful for complex request setup)
  • Color themes (all used colors and emojis are configurable, see config section)

In progress:

  • Kill / Cancel outgoing request (do not need to wait timeout for long time requests if you alredy know that the server will not respond or you've realized that outgoing request wasn't properly configured)
  • Load binary data of upload form from file
  • Config file for change key bindings, default settings

Caution

The project is under active development, features or how do they work may change!

Installation

go install github.com/1buran/rhttp@latest

❄️ Try it with Nix

It's possible to try rHttp with nix:

nix run github:nixos/nixpkgs/nixpkgs-unstable#rHttp

Key Bindings

Keys Action
Shift+Right next item of menu
Shift+Left prev item of menu
Enter set value of text intput
Ctrl+g run request
Ctrl+d delete item (param, header, form value, attached file)
Space toggle checkbox
PageDown scroll down body of response
PageUp scroll up body of response
Tab autocomplete
Ctrl+f toggle fullscreen mode
Ctl+h toggle full help
Ctrl+l load session
Ctrl+s save session
Ctrl+q / Ctrl+c quit
Ctrl+j toggle editor (edit JSON request payload)
Alt+Enter save JSON request payload
Ctrl+p load jSON request payload from file

Warning

Some of rHttp key bindigs may overriden by system settings or terminal emulator settings, please check them if you face with not working key binding.

Mini editor

Editor key bindings are from the plugin, they are most tipical shortcuts for common editors, here they are:

Keys Action
right / ctrl+f, left / ctrl+b forward, backward
alt+right / alt+f, alt+left / alt+b word forward, word backward
down / ctrl+n, up / ctrl+p line next, line previous
alt+backspace / ctrl+w, alt+delete / alt+d delete word backward, delete word forward
ctrl+k, ctrl+u delete after cursor, delete before cursor
enter / ctrl+m insert new line
backspace delete character backward
delete delete character forward
home / ctrl+a, end / ctrl+e line start, line end
ctrl+v (depends on your terminal settings) paste
alt+< / ctrl+home, alt+> / ctrl+end input begin, input end
alt+c, alt+l, alt+u capitalize, lowercase and uppercase word
ctrl+t transpose character backward

Important

Some of original texarea key bindigs are overriden by the rHttp key bindings, e.g. ctrl+h will open the help instead of delete character backward or ctrl+d will remove JSON request payload at all instead of delete character forward.

Warning

Some of original texarea key bindigs may overriden by system settings or terminal emulator settings, please check them if you face with not working key binding.

texarea key bindings

Config

You can use your own color theme and change other default settings via config.

To use a custom config you should run rHttp with param -c /path/to/config.json or place it by the path: ~/.config/rhttp/config.json

Firstly print default config to file: rhttp -print-default-config > /path/to/config.json, then modify what you wanted and run rhttp with new config: rhttp -c /path/to/config.json.

Order of overriding settings:

  • default settings
  • ~/.config/rhttp/config.json settings
  • command line arg: rHttp -c /path/to/config.json (highest priority)

Tasks

These are tasks of xc runner.

vhs

Run VHS fo update gifs.

vhs demo/main.tape
vhs demo/json-min.tape
vhs demo/load-session.tape
vhs demo/redirects.tape
vhs demo/edit-json-payload.tape
vhs demo/attach-file.tape
vhs demo/main-light.tape

imgur

Upload to Imgur and update readme.

declare -A demo=()
demo["main"]="Main demo"
demo["json-min"]="JSON min"
demo["load-session"]="Load session"
demo["redirects"]="Redirects"
demo["edit-json-payload"]="Edit JSON Payload"
demo["attach-file"]="Attach file"
demo["main-light"]="Light theme"

for i in ${!demo[@]}; do
    . .env && url=`curl --location https://api.imgur.com/3/image \
        --header "Authorization: Client-ID ${clientId}" \
        --form image=@demo/$i.gif \
        --form type=image \
        --form title=rHttp \
        --form description=Demo | jq -r '.data.link'`
    sed -i "s#^\!\[${demo[$i]}\].*#![${demo[$i]}]($url)#" README.md
done

Releases

No releases published

Packages

No packages published

Languages