Add GetQueryParam method to HtmxContext
This commit is contained in:
@@ -38,6 +38,7 @@ type HtmxContext interface {
|
|||||||
SetAllRoutes(routes []HtmxRoute)
|
SetAllRoutes(routes []HtmxRoute)
|
||||||
GetAllRoutes() []HtmxRoute
|
GetAllRoutes() []HtmxRoute
|
||||||
GetQueryParams() []HtmxPathParam
|
GetQueryParams() []HtmxPathParam
|
||||||
|
GetQueryParam(key string, defaultValue ...string) string
|
||||||
GetAuthContext() (bool, AuthContext)
|
GetAuthContext() (bool, AuthContext)
|
||||||
GetGoContext() context.Context
|
GetGoContext() context.Context
|
||||||
GetRequest() *http.Request
|
GetRequest() *http.Request
|
||||||
@@ -53,6 +54,19 @@ type HtmxContextImpl struct {
|
|||||||
routes []HtmxRoute
|
routes []HtmxRoute
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *HtmxContextImpl) GetQueryParam(key string, defaultValue ...string) string {
|
||||||
|
queryParams := c.GetQueryParams()
|
||||||
|
for _, param := range queryParams {
|
||||||
|
if param.Key == key {
|
||||||
|
return param.Value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(defaultValue) > 0 {
|
||||||
|
return defaultValue[0]
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func (c *HtmxContextImpl) GetResponseWriter() http.ResponseWriter {
|
func (c *HtmxContextImpl) GetResponseWriter() http.ResponseWriter {
|
||||||
return c.res
|
return c.res
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user