AI prompts
base on REPL for HTTP # rHttp - REPL for HTTP
[![codecov](https://codecov.io/gh/1buran/rHttp/graph/badge.svg?token=20IW0GY8R9)](https://codecov.io/gh/1buran/rHttp)
[![goreportcard](https://goreportcard.com/badge/github.com/1buran/rHttp)](https://goreportcard.com/report/github.com/1buran/redmine)
![Main demo](https://i.imgur.com/av5UlI0.gif)
#### Color themes (all used colors and emojis are configurable)
![Light theme](https://i.imgur.com/nXHdMiU.gif)
#### Responses with minified JSON
![JSON min](https://i.imgur.com/DPeROlW.gif)
#### Edit JSON request payload
![Edit JSON Payload](https://i.imgur.com/z5cLXBk.gif)
#### Load JSON request payload from file
![Attach file](https://i.imgur.com/Rxbew8A.gif)
#### Load session
![Load session](https://i.imgur.com/l7RVytc.gif)
#### Redirects
![Redirects](https://i.imgur.com/QVPx3k3.gif)
## 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](#config))
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
```sh
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](https://pkg.go.dev/github.com/charmbracelet/bubbles/textarea#pkg-variables)
## 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](https://github.com/joerdav/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
```
", Assign "at most 3 tags" to the expected json: {"id":"9559","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"