https://github.com/parametalol/hop
A stupid web service which can do stupid things told by url
https://github.com/parametalol/hop
http-server https-server kubernetes network-analysis
Last synced: 9 months ago
JSON representation
A stupid web service which can do stupid things told by url
- Host: GitHub
- URL: https://github.com/parametalol/hop
- Owner: parametalol
- License: mit
- Created: 2017-07-15T10:24:31.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2024-12-02T17:44:06.000Z (about 1 year ago)
- Last Synced: 2025-01-24T01:29:35.893Z (11 months ago)
- Topics: http-server, https-server, kubernetes, network-analysis
- Language: Go
- Homepage:
- Size: 3.1 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# hop
A stupid web service which can do stupid things told by the url.
## Usage
```console
sh$ hop --help
...
sh$ hop --port-http 8080 --port-https 8443
INFO[0000] Serving HTTP on 0.0.0.0:8080
INFO[0002] Serving HTTPS on 0.0.0.0:8443
```
```console
sh$ curl box1:8080/-wait:1000/box2:8000/-rheader:a=b
| I am box1, will do /-wait:1000/box2:8000/-rheader:a=b
| Waited for 1000 ms
| Called http://box2:8000/-rheader:a=b with status 200 OK
| With data:
| . | I am box2, will do /-rheader:a=b
| . | Will return header a: b
| .
```
## Build
### Podman
```console
sh$ cd hop
sh$ podman build -v "$PWD":/build --security-opt label=disabled -t hop:local .
sh$ podman run --rm -p 8080:8080 hop:local
```
### Go
```console
go build -o hop ./main
```
## Supported commands
```console
sh$ curl hop/-help | jq -rj '.request.process[0].output | join("\n")'
-info - return some info about the request
-rheader:H=V - add header H: V to the reponse
-code:N - responde with HTTP code N
-help - return help message
-if:H=V - execute next command if header H contains substring V
-on:H - executes next command if the server host name contains substring H
-quit - stops the server with a nice response
-size:B - add B bytes of payload to the response
-not - reverts the effect of the next boolean command (if, on)
-rnd:P - execute next command with P% probability
-wait:T - wait for T ms before response
-crash - stops the server without a response
-fheader:H - forward incoming header H to the following request
-header:H=V - add header H: V to the following request
-env:V - return the value of an environment variable
```
## Examples
Call hop1 which will show some details of the request:
```console
curl -H "a: b" hop1/-info
```
Call hop1 which will call hop2 with forwarded header A:
```console
curl -H "a: b" hop1/-fheader:a/hop2
```
Call hop1 which will call hop2 or hop3 (50%). hop2 would call hop3 and return error code 500:
```console
curl hop1/-rnd:50/hop2/hop3/-on:hop2/-code:500
```