- Published on
Go REST API Starter: Minimal and Clear
- Authors

- Name
- Mehdi Akiki
Build a tiny API first. Keep it small and readable.
Steps
- Use net/http
- One route: GET /health
- Return JSON
Code (short)
package main
import (
"encoding/json"
"net/http"
)
func main() {
http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(map[string]string{"status": "ok"})
})
http.ListenAndServe(":8080", nil)
}
Tips
- Keep handlers small
- Set content-type headers
- Return clear errors
I build and scale reliable production systems. Open to full-time and freelance work with U.S.-based teams that value ownership and execution.
Got something in mind?
Book a Discovery Call