templates/secure-go-service/skeleton/main.go

24 lines
477 B
Go

package main
import (
"fmt"
"log"
"net/http"
"os"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) {
fmt.Fprintf(w, "hello from ${{ values.name }}\n")
})
http.HandleFunc("/healthz", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
})
port := os.Getenv("PORT")
if port == "" {
port = "8080"
}
log.Printf("${{ values.name }} listening on :%s", port)
log.Fatal(http.ListenAndServe(":"+port, nil))
}