2023-09-17 14:28:54 +00:00
|
|
|
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
|
|
|
"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
|
|
|
)
|
2023-09-17 14:28:54 +00:00
|
|
|
|
2024-01-08 15:58:43 +00:00
|
|
|
//go:embed templates
|
|
|
|
var embed_templates embed.FS
|
|
|
|
|
2023-09-17 14:28:54 +00:00
|
|
|
func main() {
|
2023-09-18 09:15:19 +00:00
|
|
|
port := os.Getenv("PORT")
|
|
|
|
if port == "" {
|
|
|
|
port = "8080"
|
|
|
|
}
|
2024-01-23 14:07:28 +00:00
|
|
|
logrus.WithField("port", port).Info("starting server")
|
2023-09-17 14:28:54 +00:00
|
|
|
|
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
|
|
|
}
|
2023-09-17 14:28:54 +00:00
|
|
|
}
|