Skip to content

Commit

Permalink
Add support of edit JSON request payload
Browse files Browse the repository at this point in the history
  • Loading branch information
1buran committed Apr 5, 2024
1 parent 4954703 commit bdcb8a1
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 17 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#### Responses with minified JSON
![JSON min](https://i.imgur.com/Ii6CzZK.gif)

#### Edit JSON request payload
![Edit JSON Payload](https://i.imgur.com/VAdcP65.gif)

#### Load session
![Load session](https://i.imgur.com/TQ3uKG3.gif)

Expand All @@ -30,12 +33,12 @@ 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)
- 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)

In progress:
- Easy manipulation of JSON request payload (crud of simple data structure)
- Load JSON request payload from file
- Config file for change key bindings, default settings

Expand Down Expand Up @@ -117,4 +120,12 @@ url=`curl --location https://api.imgur.com/3/image \
--form title=rHttp \
--form description=Demo | jq -r '.data.link'`
sed -i "s#^\!\[Redirects\].*#![Redirects]($url)#" README.md
url=`curl --location https://api.imgur.com/3/image \
--header "Authorization: Client-ID ${clientId}" \
--form image=@demo/edit-json-payload.gif \
--form type=image \
--form title=rHttp \
--form description=Demo | jq -r '.data.link'`
sed -i "s#^\!\[Edit JSON Payload\].*#![[Edit JSON Payload]($url)#" README.md
```
42 changes: 42 additions & 0 deletions demo/edit-json-payload.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Output demo/edit-json-payload.gif

Set Shell "bash"
Set FontSize 16
Set Padding 2
Set Margin 2
Set Width 1280
Set Height 1024
Set Framerate 60
Set TypingSpeed 150ms
Set PlaybackSpeed 0.4
Set CursorBlink false

Require rhttp
Type "rhttp" Enter

Sleep 3
Ctrl + f
Enter
Ctrl + j
Copy "{" Paste Enter
Copy ' "name": "Gabriel",' Paste Enter
Copy ' "password": "Swordfish",' Paste Enter
Copy ' "job": "self-employed"' Paste Enter
Alt + Enter
Sleep 3
Copy "}" Paste Enter
Alt + Enter
Sleep 3
Ctrl + j
Enter
Backspace 9
Copy "reqres.in" Paste Enter
Copy "/api/users" Paste Enter
Enter 8 Space
Enter Space
Ctrl + g
PageDown 10
Sleep 3
PageUp 10
Sleep 3
Ctrl + q
12 changes: 10 additions & 2 deletions keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

type KeyMap struct {
Next, Prev, Quit, Help, Run, FullScreen, PageUp, PageDown, Up, Down, Enter,
Delete, Autocomplete, LoadSession, SaveSession, ToggleCheckbox key.Binding
Delete, Autocomplete, LoadSession, SaveSession, ToggleCheckbox, ToggleJSON, SaveJSON key.Binding
}

func (k KeyMap) ShortHelp() []key.Binding {
Expand All @@ -18,7 +18,7 @@ func (k KeyMap) FullHelp() [][]key.Binding {
return [][]key.Binding{
{k.Next, k.Prev, k.Enter, k.Run, k.Delete, k.ToggleCheckbox},
{k.FullScreen, k.Help, k.Quit, k.LoadSession, k.SaveSession, k.Autocomplete},
{k.PageDown, k.PageUp},
{k.ToggleJSON, k.SaveJSON, k.PageDown, k.PageUp},
}
}

Expand Down Expand Up @@ -79,6 +79,14 @@ var keys = KeyMap{
key.WithKeys(" "),
key.WithHelp("Space", "toggle checkbox"),
),
ToggleJSON: key.NewBinding(
key.WithKeys("ctrl+j"),
key.WithHelp("ctrl+j", "toggle JSON payload"),
),
SaveJSON: key.NewBinding(
key.WithKeys("alt+enter"),
key.WithHelp("alt+enter", "save JSON payload"),
),
}

// Helper struct for linking together help and key bindings.
Expand Down
Loading

0 comments on commit bdcb8a1

Please sign in to comment.