37 lines
755 B
Go
37 lines
755 B
Go
package routes
|
|
|
|
import (
|
|
"embed"
|
|
"html/template"
|
|
"log"
|
|
"net/http"
|
|
|
|
"sunshine.industries/some-automoderation/sessions"
|
|
)
|
|
|
|
//go:embed templates
|
|
var templateFs embed.FS
|
|
|
|
//go:embed static
|
|
var staticFilesFs embed.FS
|
|
|
|
func RegisterRoutes(sessions sessions.SessionManagement) {
|
|
// login page
|
|
registerLoginRoutes(&templateFs, sessions)
|
|
|
|
// main page template
|
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
|
var templFile = "templates/index.gohtml"
|
|
tmpl := template.Must(template.ParseFS(templateFs, templFile))
|
|
err := tmpl.Execute(w, nil)
|
|
if err != nil {
|
|
log.Printf("my error in executing template, huh\n %s", err)
|
|
}
|
|
})
|
|
|
|
// static resources route
|
|
http.Handle("/static/",
|
|
http.FileServer(http.FS(staticFilesFs)))
|
|
|
|
}
|