Files
gitlab-ci/ci/app/main.go
2022-09-19 07:47:09 +07:00

33 lines
694 B
Go

package main
import (
"net/http"
"os"
"fmt"
)
var Version = "0.0.1"
func indexHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("<h1>Hello World, im ver:"+Version+" !</h1>"))
}
func healthMessage(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Type", "application/json")
w.Write([]byte(`{"health":"OK"}`))
}
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "3000"
}
fmt.Print("\nVersion:", Version, ", Im run in http://127.0.0.1:", port)
mux := http.NewServeMux()
mux.HandleFunc("/", indexHandler)
mux.HandleFunc("/health", healthMessage)
http.ListenAndServe(":"+port, mux)
}