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
- Host: GitHub
- URL: https://github.com/sammcj/hello-world
- Owner: sammcj
- License: mit
- Created: 2023-11-01T00:34:15.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-11T06:27:56.000Z (10 months ago)
- Last Synced: 2025-01-11T13:08:27.015Z (9 months ago)
- Language: Go
- Size: 32.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)