30 lines
554 B
Go
30 lines
554 B
Go
package main
|
|
|
|
import (
|
|
"embed"
|
|
"net/http"
|
|
"os"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
"gitlab.com/mstarongitlab/weblogger"
|
|
)
|
|
|
|
//go:embed templates
|
|
var embed_templates embed.FS
|
|
|
|
func main() {
|
|
port := os.Getenv("PORT")
|
|
if port == "" {
|
|
port = "8080"
|
|
}
|
|
logrus.WithField("port", port).Info("starting server")
|
|
|
|
http.HandleFunc("/", handleRoot)
|
|
|
|
default_mux := http.DefaultServeMux
|
|
logger := weblogger.LoggingMiddleware(default_mux)
|
|
|
|
if err := http.ListenAndServe(":"+port, logger); err != nil {
|
|
logrus.WithField("event", "stop server").Fatal(err)
|
|
}
|
|
}
|