evilthings/main.go

32 lines
552 B
Go
Raw Permalink Normal View History

package main
2023-09-18 09:15:19 +00:00
import (
2024-01-08 15:58:43 +00:00
"embed"
2023-09-18 09:15:19 +00:00
"log"
"net/http"
"os"
2024-01-23 14:03:52 +00:00
"github.com/sirupsen/logrus"
"gitlab.com/mstarongitlab/weblogger"
2023-09-18 09:15:19 +00:00
)
2024-01-08 15:58:43 +00:00
//go:embed templates
var embed_templates embed.FS
func main() {
2023-09-18 09:15:19 +00:00
port := os.Getenv("PORT")
if port == "" {
port = "8080"
log.Printf("Defaulting to port %s \n", port)
}
2023-09-18 09:15:19 +00:00
http.HandleFunc("/", handleRoot)
2024-01-23 14:03:52 +00:00
default_mux := http.DefaultServeMux
logger := weblogger.LoggingMiddleware(default_mux)
if err := http.ListenAndServe(":"+port, logger); err != nil {
logrus.WithField("event", "stop server").Fatal(err)
2023-09-18 09:15:19 +00:00
}
}