Add the ability to toggle filtering URL parameters passed to page providers.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ac08289073
commit
7ec2e01e43
@ -4,5 +4,6 @@ type ServeYaml struct {
|
|||||||
DataStorage string `yaml:"dataStorage"`
|
DataStorage string `yaml:"dataStorage"`
|
||||||
Domains []string `yaml:"domains"`
|
Domains []string `yaml:"domains"`
|
||||||
RangeSupported bool `yaml:"rangeSupported"`
|
RangeSupported bool `yaml:"rangeSupported"`
|
||||||
|
FilterURLQueries bool `yaml:"filterURLQueries"`
|
||||||
CacheSettings CacheSettingsYaml `yaml:"cacheSettings"`
|
CacheSettings CacheSettingsYaml `yaml:"cacheSettings"`
|
||||||
}
|
}
|
||||||
|
13
config.example.yml
Normal file
13
config.example.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
listen:
|
||||||
|
webNetwork: "tcp4"
|
||||||
|
web: ":8080"
|
||||||
|
webMethod: "http"
|
||||||
|
identify: true
|
||||||
|
serve:
|
||||||
|
rangeSupported: true
|
||||||
|
cacheSettings:
|
||||||
|
enableContentsCaching: true
|
||||||
|
enableContentsCachePurge: true
|
||||||
|
maxAge: 3600
|
||||||
|
notModifiedUsingLastModified: true
|
||||||
|
notModifiedUsingETags: true
|
@ -19,6 +19,7 @@ type PageHandler struct {
|
|||||||
PageProviders map[string]PageProvider
|
PageProviders map[string]PageProvider
|
||||||
pageContentsCacheRWMutex *sync.RWMutex
|
pageContentsCacheRWMutex *sync.RWMutex
|
||||||
RangeSupported bool
|
RangeSupported bool
|
||||||
|
FilterURLQueries bool
|
||||||
CacheSettings conf.CacheSettingsYaml
|
CacheSettings conf.CacheSettingsYaml
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,6 +41,7 @@ func NewPageHandler(config conf.ServeYaml) *PageHandler {
|
|||||||
PageProviders: GetProviders(config.CacheSettings.EnableTemplateCaching, config.DataStorage),
|
PageProviders: GetProviders(config.CacheSettings.EnableTemplateCaching, config.DataStorage),
|
||||||
pageContentsCacheRWMutex: theMutex,
|
pageContentsCacheRWMutex: theMutex,
|
||||||
RangeSupported: config.RangeSupported,
|
RangeSupported: config.RangeSupported,
|
||||||
|
FilterURLQueries: config.FilterURLQueries,
|
||||||
CacheSettings: config.CacheSettings,
|
CacheSettings: config.CacheSettings,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,7 +164,10 @@ func (ph *PageHandler) GetCleanQuery(request *http.Request) (url.Values, string)
|
|||||||
return make(url.Values), ""
|
return make(url.Values), ""
|
||||||
}
|
}
|
||||||
supportedKeys := provider.GetSupportedURLParameters()
|
supportedKeys := provider.GetSupportedURLParameters()
|
||||||
toDelete := make([]string, len(toClean))
|
var toDelete []string
|
||||||
|
if ph.FilterURLQueries {
|
||||||
|
toDelete = make([]string, len(toClean))
|
||||||
|
}
|
||||||
theSize := 0
|
theSize := 0
|
||||||
theQuery := ""
|
theQuery := ""
|
||||||
for s, v := range toClean {
|
for s, v := range toClean {
|
||||||
@ -174,8 +179,10 @@ func (ph *PageHandler) GetCleanQuery(request *http.Request) (url.Values, string)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if noExist {
|
if noExist {
|
||||||
|
if ph.FilterURLQueries {
|
||||||
toDelete[theSize] = s
|
toDelete[theSize] = s
|
||||||
theSize++
|
theSize++
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for _, i := range v {
|
for _, i := range v {
|
||||||
if i == "" {
|
if i == "" {
|
||||||
@ -186,9 +193,11 @@ func (ph *PageHandler) GetCleanQuery(request *http.Request) (url.Values, string)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ph.FilterURLQueries {
|
||||||
for i := 0; i < theSize; i++ {
|
for i := 0; i < theSize; i++ {
|
||||||
delete(toClean, toDelete[i])
|
delete(toClean, toDelete[i])
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return toClean, strings.TrimRight(theQuery, "&")
|
return toClean, strings.TrimRight(theQuery, "&")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user