func()

in main.go [177:204]


func (s *Server) index(dashboards []*Dash, tmpl *template.Template) http.HandlerFunc {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		// return 404 if not the root
		if r.URL.Path != "/" {
			http.NotFound(w, r)
			return
		}

		data := &indexData{
			Dashboards: dashboards,
			Config:     s.config,
		}

		if s.config.OAuthEnabled {
			session, _ := gothic.Store.Get(r, sessionName)
			if email, ok := session.Values["current_user_email"]; ok {
				data.User = &goth.User{
					Email: email.(string),
				}
			}
		}

		if err := tmpl.Execute(w, data); err != nil {
			log.Error().Err(err).Send()
			http.Error(w, "500 Internal Server Error", http.StatusInternalServerError)
		}
	})
}