diff options
author | Wolfy-J <[email protected]> | 2019-01-10 11:53:16 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2019-01-10 11:53:16 +0300 |
commit | 35bd2c861daf7a3895dc9d99642b53f2107bf5bf (patch) | |
tree | a47f3ef674824e0138783d443bb6c0afb483314e /service/static/config.go | |
parent | d1532db3043a1038f287fe31d1f2537d37d4d3a9 (diff) |
always serve files
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 +} |