// Minimal HTTP service for testing AISP's Gitea -> build -> release -> deploy flow. package main import ( "encoding/json" "log" "net/http" "os" "time" ) const version = "v1" // Test func main() { port := getenv("PORT", "8080") hostname, _ := os.Hostname() startedAt := time.Now().UTC().Format(time.RFC3339) http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) { reply(w, http.StatusOK, map[string]string{"status": "ok"}) }) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { if r.URL.Path != "/" { reply(w, http.StatusNotFound, map[string]string{"error": "not found"}) return } log.Printf("%s %s %s", r.RemoteAddr, r.Method, r.URL.Path) reply(w, http.StatusOK, map[string]string{ "service": "aisp-ci-demo", "version": version, "message": getenv("APP_MESSAGE", "Hello from AISP"), "hostname": hostname, "startedAt": startedAt, }) }) log.Printf("aisp-ci-demo %s listening on :%s", version, port) log.Fatal(http.ListenAndServe(":"+port, nil)) } func reply(w http.ResponseWriter, status int, body any) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(status) _ = json.NewEncoder(w).Encode(body) } func getenv(key, fallback string) string { if value := os.Getenv(key); value != "" { return value } return fallback }