An open API service indexing awesome lists of open source software.

https://github.com/sammcj/hello-world

Hello World Golang API App for Testing
https://github.com/sammcj/hello-world

Last synced: 8 months ago
JSON representation

Hello World Golang API App for Testing

Awesome Lists containing this project

README

          

# Hello World

Hello World application written in Go.

## Features

- Always returns a HTTP 200 status code and a "Hello, World!" message at the / path.
- Has a metrics endpoint at /metrics that returns Prometheus metrics.
- Has a health check endpoint, /health, that returns an empty response and a HTTP 200 response.

## Build

```bash
make deps
make build
```

or

```bash
docker-compose build
```

## Usage

### local

```bash
./hello_world
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
- using env: export GIN_MODE=release
- using code: gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET /metrics --> github.com/zsais/go-gin-prometheus.(*Prometheus).SetMetricsPath.prometheusHandler.func2 (4 handlers)
[GIN-debug] GET /health --> main.healthFunc (6 handlers)
[GIN-debug] GET / --> main.helloFunc (6 handlers)
[GIN-debug] GET /version --> main.versionFunc (6 handlers)
[GIN-debug] Environment variable PORT is undefined. Using port :8080 by default
[GIN-debug] Listening and serving HTTP on :8080
```

### Docker

```bash
docker run \
--detach \
--name hello-world \
--publish 8080:8080 \
ghcr.io/sammcj/hello-world
```

curl the container

`curl http://0.0.0.0:8080/`

curl the health check endpoint which returns an empty 200 response

`curl http://0.0.0.0:8080/health`

curl Prometheus metrics

`curl http://0.0.0.0:8080/metrics`

## Acknowledgements

- [infrastructure-as-code/docker-hello-world](https://github.com/infrastructure-as-code/docker-hello-world)