generated from moebiusband/go-http-skeleton
23 lines
644 B
Go
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
|
|
}
|