federated-dash/cmd/web/main.go

47 lines
915 B
Go
Raw Normal View History

2024-06-25 17:35:30 +00:00
package main
import (
"html/template"
"log/slog"
"net/http"
"os"
"flag"
)
2024-06-25 21:28:39 +00:00
//TODO Get images for each app
//TODO Stylesheet
//TODO VPN Page
//TODO Auth through LDAP for VPN page
2024-06-25 17:35:30 +00:00
type application struct {
logger *slog.Logger
templateCache map[string]*template.Template
2024-06-25 20:17:08 +00:00
tier string
2024-06-25 17:35:30 +00:00
}
func main() {
//Get env variables
addr := flag.String("addr", ":4000", "HTTP network address")
2024-06-25 20:17:08 +00:00
tier := flag.String("tier", "starter", "tier the core is on")
flag.Parse()
2024-06-25 17:35:30 +00:00
//Set up logger
logger := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
AddSource: true,
}))
//Set up template cache
templateCache, err := newTemplateCache()
if err != nil {
logger.Error(err.Error())
os.Exit(1)
}
//Set up application data
app := application {
logger: logger,
templateCache: templateCache,
2024-06-25 20:17:08 +00:00
tier: *tier,
2024-06-25 17:35:30 +00:00
}
err = http.ListenAndServe(*addr, app.routes())
logger.Error(err.Error())
os.Exit(1)
}