diff options
Diffstat (limited to 'service/static/config.go')
-rw-r--r-- | service/static/config.go | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/service/static/config.go b/service/static/config.go index 5df7b013..ebc9af2a 100644 --- a/service/static/config.go +++ b/service/static/config.go @@ -16,6 +16,10 @@ type Config struct { // Forbid specifies list of file extensions which are forbidden for access. // Example: .php, .exe, .bat, .htaccess and etc. Forbid []string + + // Serve specifies list of exceptions which must always be served by static + // service, even if file not found. + Always []string } // Hydrate must populate Config values using given Config source. Must return error if Config is not valid. @@ -45,8 +49,8 @@ func (c *Config) Valid() error { return nil } -// Forbids must return true if file extension is not allowed for the upload. -func (c *Config) Forbids(filename string) bool { +// AlwaysForbid must return true if file extension is not allowed for the upload. +func (c *Config) AlwaysForbid(filename string) bool { ext := strings.ToLower(path.Ext(filename)) for _, v := range c.Forbid { @@ -57,3 +61,16 @@ func (c *Config) Forbids(filename string) bool { return false } + +// AlwaysServe must indicate that file is expected to be served by static service. +func (c *Config) AlwaysServe(filename string) bool { + ext := strings.ToLower(path.Ext(filename)) + + for _, v := range c.Always { + if ext == v { + return true + } + } + + return false +} |