1buran/rHttp

REPL for HTTP

Go

547

103 commits

updated Jul 20, 2024

See the code

README

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

KeysAction
Shift+Rightnext item of menu
Shift+Leftprev item of menu
Enterset value of text intput
Ctrl+grun request
Ctrl+ddelete item (param, header, form value, attached file)
Spacetoggle checkbox
PageDownscroll down body of response
PageUpscroll up body of response
Tabautocomplete
Ctrl+ftoggle fullscreen mode
Ctl+htoggle full help
Ctrl+lload session
Ctrl+ssave session
Ctrl+q / Ctrl+cquit
Ctrl+jtoggle editor (edit JSON request payload)
Alt+Entersave JSON request payload
Ctrl+pload 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:

KeysAction
right / ctrl+f, left / ctrl+bforward, backward
alt+right / alt+f, alt+left / alt+bword forward, word backward
down / ctrl+n, up / ctrl+pline next, line previous
alt+backspace / ctrl+w, alt+delete / alt+ddelete word backward, delete word forward
ctrl+k, ctrl+udelete after cursor, delete before cursor
enter / ctrl+minsert new line
backspacedelete character backward
deletedelete character forward
home / ctrl+a, end / ctrl+eline start, line end
ctrl+v (depends on your terminal settings)paste
alt+< / ctrl+home, alt+> / ctrl+endinput begin, input end
alt+c, alt+l, alt+ucapitalize, lowercase and uppercase word
ctrl+ttranspose 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
http-cli
repl
tui

1buran/rHttp

REPL for HTTP

Go

547

103 commits

updated Jul 20, 2024

See the code

README

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

KeysAction
Shift+Rightnext item of menu
Shift+Leftprev item of menu
Enterset value of text intput
Ctrl+grun request
Ctrl+ddelete item (param, header, form value, attached file)
Spacetoggle checkbox
PageDownscroll down body of response
PageUpscroll up body of response
Tabautocomplete
Ctrl+ftoggle fullscreen mode
Ctl+htoggle full help
Ctrl+lload session
Ctrl+ssave session
Ctrl+q / Ctrl+cquit
Ctrl+jtoggle editor (edit JSON request payload)
Alt+Entersave JSON request payload
Ctrl+pload 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:

KeysAction
right / ctrl+f, left / ctrl+bforward, backward
alt+right / alt+f, alt+left / alt+bword forward, word backward
down / ctrl+n, up / ctrl+pline next, line previous
alt+backspace / ctrl+w, alt+delete / alt+ddelete word backward, delete word forward
ctrl+k, ctrl+udelete after cursor, delete before cursor
enter / ctrl+minsert new line
backspacedelete character backward
deletedelete character forward
home / ctrl+a, end / ctrl+eline start, line end
ctrl+v (depends on your terminal settings)paste
alt+< / ctrl+home, alt+> / ctrl+endinput begin, input end
alt+c, alt+l, alt+ucapitalize, lowercase and uppercase word
ctrl+ttranspose 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
http-cli
repl
tui

Significant stargazers

Jeremiah Senkpiel

673 followers · starred Apr 2024

Bruno Heridet

253 followers · starred Apr 2024

Daniel Graña

388 followers · starred Apr 2024

Marc Falzon

93 followers · starred Apr 2024