Add GetHeaderValue, as well as req/res getters

This commit is contained in:
Achim Rohn
2025-12-26 11:34:57 +01:00
parent 9a3fb06c7a
commit 8e5f636c09
+15
View File
@@ -33,12 +33,15 @@ type HtmxContext interface {
SetPathTemplate(pathTemplate string)
GetPathParam(key string, defaultValue ...string) string
GetFormValue(key string) string
GetHeaderValue(key string) string
SetHeader(key string, value string)
SetAllRoutes(routes []HtmxRoute)
GetAllRoutes() []HtmxRoute
GetQueryParams() []HtmxPathParam
GetAuthContext() (bool, AuthContext)
GetGoContext() context.Context
GetRequest() *http.Request
GetResponseWriter() http.ResponseWriter
}
type HtmxContextImpl struct {
@@ -50,6 +53,18 @@ type HtmxContextImpl struct {
routes []HtmxRoute
}
func (c *HtmxContextImpl) GetResponseWriter() http.ResponseWriter {
return c.res
}
func (c *HtmxContextImpl) GetRequest() *http.Request {
return c.req
}
func (c *HtmxContextImpl) GetHeaderValue(key string) string {
return c.req.Header.Get(key)
}
func (c *HtmxContextImpl) GetGoContext() context.Context {
return c.req.Context()
}