go-http-skeleton/web/routes.go
Jan Eitzinger f15d6b2163
Initial checkin of templ skeleton
HTML based on Jason Knight HTML template code
2024-08-03 08:51:30 +02:00

23 lines
644 B
Go

package web
import (
"net/http"
"time"
"git.clustercockpit.org/moebiusband/go-http-skeleton/web/components"
"github.com/a-h/templ"
"github.com/benbjohnson/hashfs"
"github.com/gorilla/sessions"
)
func setupRoutes(r *http.ServeMux) error {
r.Handle("GET /static/", hashfs.FileServer(staticSys))
r.Handle("GET /{$}", templ.Handler(components.Page(components.IndexPage())))
r.Handle("GET /404", templ.Handler(components.Page(components.Page404()), templ.WithStatus(http.StatusNotFound)))
sessionStore := sessions.NewCookieStore([]byte("datastar-session-secret"))
sessionStore.MaxAge(int(24 * time.Hour / time.Second))
return nil
}