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
@ -1,8 +1,9 @@
|
||||
package conf
|
||||
|
||||
type ServeYaml struct {
|
||||
DataStorage string `yaml:"dataStorage"`
|
||||
Domains []string `yaml:"domains"`
|
||||
RangeSupported bool `yaml:"rangeSupported"`
|
||||
CacheSettings CacheSettingsYaml `yaml:"cacheSettings"`
|
||||
DataStorage string `yaml:"dataStorage"`
|
||||
Domains []string `yaml:"domains"`
|
||||
RangeSupported bool `yaml:"rangeSupported"`
|
||||
FilterURLQueries bool `yaml:"filterURLQueries"`
|
||||
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
|
||||
pageContentsCacheRWMutex *sync.RWMutex
|
||||
RangeSupported bool
|
||||
FilterURLQueries bool
|
||||
CacheSettings conf.CacheSettingsYaml
|
||||
}
|
||||
|
||||
@ -40,6 +41,7 @@ func NewPageHandler(config conf.ServeYaml) *PageHandler {
|
||||
PageProviders: GetProviders(config.CacheSettings.EnableTemplateCaching, config.DataStorage),
|
||||
pageContentsCacheRWMutex: theMutex,
|
||||
RangeSupported: config.RangeSupported,
|
||||
FilterURLQueries: config.FilterURLQueries,
|
||||
CacheSettings: config.CacheSettings,
|
||||
}
|
||||
}
|
||||
@ -162,7 +164,10 @@ func (ph *PageHandler) GetCleanQuery(request *http.Request) (url.Values, string)
|
||||
return make(url.Values), ""
|
||||
}
|
||||
supportedKeys := provider.GetSupportedURLParameters()
|
||||
toDelete := make([]string, len(toClean))
|
||||
var toDelete []string
|
||||
if ph.FilterURLQueries {
|
||||
toDelete = make([]string, len(toClean))
|
||||
}
|
||||
theSize := 0
|
||||
theQuery := ""
|
||||
for s, v := range toClean {
|
||||
@ -174,8 +179,10 @@ func (ph *PageHandler) GetCleanQuery(request *http.Request) (url.Values, string)
|
||||
}
|
||||
}
|
||||
if noExist {
|
||||
toDelete[theSize] = s
|
||||
theSize++
|
||||
if ph.FilterURLQueries {
|
||||
toDelete[theSize] = s
|
||||
theSize++
|
||||
}
|
||||
} else {
|
||||
for _, i := range v {
|
||||
if i == "" {
|
||||
@ -186,8 +193,10 @@ func (ph *PageHandler) GetCleanQuery(request *http.Request) (url.Values, string)
|
||||
}
|
||||
}
|
||||
}
|
||||
for i := 0; i < theSize; i++ {
|
||||
delete(toClean, toDelete[i])
|
||||
if ph.FilterURLQueries {
|
||||
for i := 0; i < theSize; i++ {
|
||||
delete(toClean, toDelete[i])
|
||||
}
|
||||
}
|
||||
return toClean, strings.TrimRight(theQuery, "&")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user