Categorygithub.com/nabeken/go-api-now
modulepackage
1.2.0
Repository: https://github.com/nabeken/go-api-now.git
Documentation: pkg.go.dev

# README

go-api-now

This is a very basic HTTP API that returns current time and environment in Go.

In default, the api server is listening to tcp/8000. You can change the port by specifying PORT environment variable.

Why?

Sometimes I want to test Docker integration so I need a container image suitable for testing.

e.g.

  • AWS ECS integration
  • AWS CodeDeploy integration
  • Kubernetes integration
  • Heroku integration
  • ...

Endpoints

  • GET /
    • returns the current environment variables
    • ?sleep=<duration>: sleep <duration> before returns a response
  • GET /json
    • returns the large JSON file
  • GET /_stats
    • returns the current Go's runtime stats

Usage

Build:

$ docker build -t nabeken/go-api-now:latest .

Run:

$ docker run -d -p 8000:8000 nabeken/go-api-now:latest
$ curl -i http://<docker>:8000

Or

$ docker run -d -p 9999:9999 -e PORT=9999 nabeken/go-api-now:latest
$ curl -i http://<docker>:9999

# Functions

HTTP runs the HTTP server.

# Variables

Version is to embed the version string.