import demo-app template
build / build (push) Has been cancelled

This commit is contained in:
admin
2026-05-26 13:52:14 +04:00
parent 69f64da7c4
commit b48b20c926
5 changed files with 123 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
package main
import (
"encoding/json"
"log"
"net/http"
"os"
)
var version = os.Getenv("APP_VERSION")
type status struct {
Status string `json:"status"`
Version string `json:"version"`
}
func main() {
if version == "" {
version = "dev"
}
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(status{Status: "ok", Version: version})
})
http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
_, _ = w.Write([]byte("ok"))
})
addr := ":8080"
log.Printf("listening on %s, version=%s", addr, version)
log.Fatal(http.ListenAndServe(addr, nil))
}