- Go module (github.com/elfoundation/hatch) with go 1.25 - cmd/hatch: HTTP server with GET /healthz returning 200 OK - Multi-stage Dockerfile producing static binary from scratch - docker-compose with hatch + optional Caddy reverse proxy - CI placeholder with Go test/lint stubs - .gitignore, .dockerignore, .env.example Co-Authored-By: Paperclip <noreply@paperclip.ing>
37 lines
842 B
Go
37 lines
842 B
Go
// Command hatch is the Hatch HTTP request inspector + mocker server.
|
|
//
|
|
// Hatch captures, inspects, and mocks HTTP requests. It ships as a single
|
|
// static binary — one command on a VPS and your payloads never leave your
|
|
// network.
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
port := os.Getenv("PORT")
|
|
if port == "" {
|
|
port = "8080"
|
|
}
|
|
|
|
mux := http.NewServeMux()
|
|
mux.HandleFunc("GET /healthz", healthz)
|
|
|
|
addr := fmt.Sprintf(":%s", port)
|
|
log.Printf("hatch starting on %s", addr)
|
|
if err := http.ListenAndServe(addr, mux); err != nil {
|
|
log.Fatalf("hatch server error: %v", err)
|
|
}
|
|
}
|
|
|
|
// healthz returns 200 OK with body "ok" for liveness probes.
|
|
func healthz(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Content-Type", "text/plain")
|
|
w.WriteHeader(http.StatusOK)
|
|
fmt.Fprintln(w, "ok")
|
|
}
|