Skip to content

haohuman/header-checker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

header-checker

A simple HTTP service written in Go that receives requests and prints all request headers.

Features

  • Listens on port :8080
  • Logs all request headers to the terminal
  • Returns request method, path, and all headers in the HTTP response as plain text
  • Uses a panic recover middleware to catch panics and respond with HTTP 500

Run locally

go run main.go

Then visit:

curl -H "X-Test: hello" http://localhost:8080/

Or open http://localhost:8080/ in your browser to see the headers.

Build locally

make build

This produces a binary named header-checker.

Run with Docker

Build the image:

make docker-build

Run the container:

make docker-run

Then visit http://localhost:8080/.

Multi-arch build and push to Docker Hub

The Makefile includes a target using docker buildx for multi-architecture builds.

First log in to Docker Hub:

docker login

Build and push (replace with your own Docker Hub username):

make docker-buildx-push DOCKER_USER=your-dockerhub-username

This builds for linux/amd64 and linux/arm64 and pushes the image to:

your-dockerhub-username/header-checker:latest

About

a request header checker

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors