Add state

This commit is contained in:
Henri Burau
2024-06-03 23:54:45 +02:00
parent ca04cc51f3
commit a793da1307
30 changed files with 553 additions and 88 deletions

View File

@ -22,6 +22,23 @@ type Server struct {
cs *services.CaptureService
}
func NewServer(cs *services.CaptureService) *Server {
return &Server{
cs,
}
}
func Render(w http.ResponseWriter, r *http.Request, c templ.Component) error {
return c.Render(r.Context(), w)
}
func hxRedirect(w http.ResponseWriter, r *http.Request, url string) error {
if len(r.Header.Get("HX-Request")) > 0 {
w.Header().Set("hx-redirect", url)
w.WriteHeader(http.StatusSeeOther)
return nil
}
http.Redirect(w, r, url, http.StatusSeeOther)
return nil
}