43 lines
984 B
Go
43 lines
984 B
Go
package main
|
|
|
|
import (
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
"gitea.teamortix.com/Team-Ortix/blgo/handler"
|
|
)
|
|
|
|
func main() {
|
|
created, err := createDefaultConfig()
|
|
switch {
|
|
case err != nil:
|
|
logrus.Fatalf("Error while reading config file: %v", err)
|
|
case created:
|
|
logrus.Info("The default config file has been created. Please edit it and re-run the program.")
|
|
return
|
|
}
|
|
|
|
cfg, err := parseConfig()
|
|
if err != nil {
|
|
logrus.Fatalf("Error while parsing the config: %v", err)
|
|
}
|
|
|
|
logrus.Info("Parsing template theme \"", cfg.ThemeName, "\"...")
|
|
err = handler.SetTheme(cfg.ThemeName)
|
|
if err != nil {
|
|
logrus.Fatalf("Error while parsing templates: %v", err)
|
|
}
|
|
logrus.Info("Completed template parsing.")
|
|
|
|
http.HandleFunc("/", handler.Handler)
|
|
|
|
portStr := strconv.Itoa(cfg.Port)
|
|
logrus.Info("Listening on port " + portStr + "...")
|
|
err = http.ListenAndServe(":"+portStr, nil)
|
|
if err != nil {
|
|
logrus.Fatalf("error while listen and serving: %v", err)
|
|
}
|
|
}
|