https://github.com/sha1n/hako
Hako is a handy echo HTTP server utility with a simple CLI interface. Also available as a Docker image.
https://github.com/sha1n/hako
cli cli-interface developer-tools docker-image echo echo-server hako http-server utility
Last synced: 3 months ago
JSON representation
Hako is a handy echo HTTP server utility with a simple CLI interface. Also available as a Docker image.
- Host: GitHub
- URL: https://github.com/sha1n/hako
- Owner: sha1n
- License: mit
- Created: 2020-03-12T14:56:50.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2025-02-17T14:17:39.000Z (3 months ago)
- Last Synced: 2025-02-17T15:26:25.631Z (3 months ago)
- Topics: cli, cli-interface, developer-tools, docker-image, echo, echo-server, hako, http-server, utility
- Language: Go
- Homepage: https://sha1n.github.io/hako/
- Size: 227 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/sha1n/hako/actions/workflows/go.yml)

[](https://goreportcard.com/report/sha1n/hako)
[](https://coveralls.io/github/sha1n/hako?branch=master)
[](https://github.com/sha1n/hako/releases)
[](https://opensource.org/licenses/MIT)
[](https://github.com/sha1n/hako/actions/workflows/release-drafter.yml)- [Hako](#hako)
- [Installation](#installation)
- [Install From a Homebrew Tap](#install-from-a-homebrew-tap)
- [Downloading released binaries](#downloading-released-binaries)
- [Pulling a Public Docker Image](#pulling-a-public-docker-image)
- [Building from sources](#building-from-sources)
- [Building docker image from sources](#building-docker-image-from-sources)
- [Usage](#usage)# Hako
Hako is an HTTP echo server with a CLI interface that provides some extra features. Hako has been developed to help me develop and test one of my projects and since the need for such utility keeps popping every few years, I thought it would be nice to share it with others.## Installation
### Install From a Homebrew Tap
```
# Tap the repository
brew tap sha1n/tap# Install
brew install hako# Update
brew upgrade hako
```### Downloading released binaries
**MacOS cURL Example**
```bash
curl -Lf --compressed -o <~/.local/bin/hako> https://github.com/sha1n/hako/releases/download/v0.6.1/hako-darwin-amd64chmod +x <~/.local/bin/hako>
```### Pulling a Public Docker Image
```
docker pull sha1n/hako# you can then start the server using
docker run sha1n/hako
# or with custom arguments
docker run -p 8090:8080 sha1n/hako /bin/sh -c "/opt/hako start --path /echo/shmecho --delay 1 --verbose --verbose-headers"
```### Building from sources
```bash
git clone [email protected]:sha1n/hako.git
cd hako# build the Go app (a local Go installation is required)
make# optionally copy the binary to your path
cp bin/hako <~/.local/bin/hako>
```### Building docker image from sources
Use the following command to build a docker image from the local sources. The image will be tagged `hako:latest`.
```bash
make build-docker
```## Usage
Use `hako --help` for help.**Terminal A:**
```bash
# run the server
➜ ~ hako start -p 8090 --path /echo/shmecho --delay 1 --verbose --verbose-headers
# or using the published docker image
➜ ~ docker run -p 8090:8080 sha1n/hako /bin/sh -c "/opt/hako start --path /echo/shmecho --delay 1 --verbose --verbose-headers"
[HAKO] 2020/03/17 12:32:36 Registering signal listeners for graceful HTTP server shutdown..
[HAKO] 2020/03/17 12:32:36 Staring HTTP Server on :8090
[HAKO] 2020/03/17 12:32:36 Waiting for shutdown signal...
[HAKO] 2020/03/17 12:32:38 Handling request at /echo/shmecho
[HAKO] 2020/03/17 12:32:38 Received headers:User-Agent : curl/7.64.1
Accept : */*
Content-Type : application/json
Content-Length : 18[HAKO] 2020/03/17 12:32:38 Received body:
{'Hello': 'World'}
[HAKO] 2020/03/17 12:32:38 Delaying response in 1 millis
[GIN] 2020/03/17 - 12:32:38 | 200 | 1.328925ms | ::1 | POST /echo/shmecho
[HAKO] 2020/03/17 12:33:44 Handling request at /non-existing
[GIN] 2020/03/17 - 12:33:44 | 404 | 14.822µs | ::1 | HEAD /non-existing
```**Terminal B:**
```bash
# posting to an existing URL
➜ ~ curl -X POST localhost:8090/echo/shmecho -H "Content-Type: application/json" --data "{'Hello': 'World'}"
{'Hello': 'World'}%# heading to a non-existing URL
➜ ~ curl -I localhost:8090/non-existing
HTTP/1.1 404 Not Found
Content-Type: text/plain
Date: Tue, 17 Mar 2020 10:33:44 GMT
Content-Length: 18
```