Add state
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user