Skip to content

sepetrov/hello-world

Repository files navigation

hello-world

This repository contains a Go HTTP server with configurable response. The CI builds a Docker image and pushes it to Docker Hub at https://hub.docker.com/repository/docker/sepetrov/hello-world.

Usage

Pull and run the container from Docker Hub:

docker run --rm -p 8080:8080 sepetrov/hello-world:latest
default content type: text/plain
default status code: 200
default response body: Hello World!
start listening on port 8080

Make a request to the running container. This will return the default response: Hello World!.

curl -i http://localhost:8080
HTTP/1.1 200 OK
Content-Type: text/plain
Date: Tue, 30 Dec 2025 09:34:46 GMT
Content-Length: 12

Hello World!

Configuration

The response can be customized using environment variables:

  • SERVER_PORT: sets the server listening port (default: 8080)
  • CONTENT_TYPE: sets the Content-Type header (default: text/plain)
  • STATUS_CODE: sets the HTTP status code (default: 200)
  • RESPONSE_BODY: sets the response body (default: Hello World!)
docker run --rm -p 8080:8088 -e SERVER_PORT=8088 -e CONTENT_TYPE=application/json -e STATUS_CODE=201 -e RESPONSE_BODY='{"status":"ok"}' sepetrov/hello-world:latest
default content type: application/json
default status code: 201
default response body: {"status":"ok"}
start listening on port 8088
curl -i http://localhost:8080                                                                                        
HTTP/1.1 201 Created
Content-Type: application/json
Date: Tue, 30 Dec 2025 09:48:32 GMT
Content-Length: 15

{"status":"ok"}

Request-time Customisation

Alternatively, the response can be customised by the caller using query or POST parameters:

  • content_type: sets the Content-Type header
  • status_code: sets the HTTP status code
  • response_body: sets the response body
curl -i 'http://localhost:8080?status_code=404' -d 'response_body=Not Found'             
HTTP/1.1 404 Not Found
Content-Type: text/plain
Date: Tue, 30 Dec 2025 09:50:18 GMT
Content-Length: 22

Not Found

About

HTTP server with configurable response

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published