package main import ( "log" "net/http" "os" ) var ( SigningToken = os.Getenv("SIGNING_TOKEN") ) func main() { listenAddr := os.Getenv("LISTEN_ADDR") if listenAddr == "" { listenAddr = "0.0.0.0:8555" } mux := http.NewServeMux() mux.HandleFunc("/hook/{token}", postGetHookToken) log.Println("[main] http server listening on", listenAddr) err := http.ListenAndServe(listenAddr, mux) if err != nil { log.Fatalln("[main] http server errored", err) } } func errMethodNotAllowed(rw http.ResponseWriter) { rw.Header().Add("content-type", "text/plain") rw.WriteHeader(http.StatusMethodNotAllowed) rw.Write([]byte("405 Method Not Allowed")) } func errStatusInternalServerError(rw http.ResponseWriter) { rw.Header().Add("content-type", "text/plain") rw.WriteHeader(http.StatusInternalServerError) rw.Write([]byte("500 Internal Server Error")) } func errUnauthorized(rw http.ResponseWriter) { rw.Header().Add("content-type", "text/plain") rw.WriteHeader(http.StatusUnauthorized) rw.Write([]byte("401 Unauthorized")) } func errBadRequest(rw http.ResponseWriter) { rw.Header().Add("content-type", "text/plain") rw.WriteHeader(http.StatusBadRequest) rw.Write([]byte("401 Bad Request")) } func basicOk(rw http.ResponseWriter) { rw.Header().Add("content-type", "text/plain") rw.WriteHeader(http.StatusOK) rw.Write([]byte("200 Aight Request")) } func basicNoContent(rw http.ResponseWriter) { rw.Header().Add("content-type", "text/plain") rw.WriteHeader(http.StatusNoContent) rw.Write([]byte("204 No Content (debug: likely not handled)")) }