package grilist import ( "database/sql" "log" "net" "net/http" "strings" "fagott.pw/charakterin" "fagott.pw/grilist/eventlogging" "fagott.pw/grilist/frontend" "github.com/julienschmidt/httprouter" _ "github.com/lib/pq" ) // Grilist struct type Grilist struct { Config Config Renderer *frontend.Renderer Charakterin *charakterin.Charakterin DB *sql.DB Modules map[string]Module Router *httprouter.Router } func (g *Grilist) EventLogger(r *http.Request) *eventlogging.EventLogger { forwardedIPs := strings.Split(r.Header.Get("X-Forwarded-For"), ", ") ip := r.RemoteAddr if len(forwardedIPs) > 0 && forwardedIPs[0] != "" { ip = forwardedIPs[0] } host, _, err := net.SplitHostPort(ip) if err != nil { log.Printf("Could not split IP %s\n", ip) log.Println(err) host = "0.0.0.0" } return eventlogging.NewEventLogger(host) } // Module ist ein Modul für Grilist. type Module interface { Init(*Grilist) Name() string ProvideDashboardData(*charakterin.User) []DashboardCategory } // DashboardCategory ist eine Kategorie mit Karten, die auf dem Dashboard angezeigt werden. type DashboardCategory struct { Title string Cards []frontend.Card }