diff options
author | Valery Piashchynski <[email protected]> | 2021-04-25 20:18:35 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-04-25 20:18:35 +0300 |
commit | f6359114607f9daa41aa90d452ebdc970615c3ab (patch) | |
tree | d1bc215440949d6615b2c645396e0146843745fa /plugins/static/config.go | |
parent | 92d089e0ecedaa1ccdf9e2700b9cb2b61f307b1d (diff) |
- Initial commit of the updated static plugin
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'plugins/static/config.go')
-rw-r--r-- | plugins/static/config.go | 36 |
1 files changed, 6 insertions, 30 deletions
diff --git a/plugins/static/config.go b/plugins/static/config.go index 90efea76..2519c04f 100644 --- a/plugins/static/config.go +++ b/plugins/static/config.go @@ -2,8 +2,6 @@ package static import ( "os" - "path" - "strings" "github.com/spiral/errors" ) @@ -14,10 +12,14 @@ type Config struct { // Dir contains name of directory to control access to. Dir string - // Forbid specifies list of file extensions which are forbidden for access. - // Example: .php, .exe, .bat, .htaccess and etc. + // forbid specifies list of file extensions which are forbidden for access. + // example: .php, .exe, .bat, .htaccess and etc. Forbid []string + // Allow specifies list of file extensions which are allowed for access. + // example: .php, .exe, .bat, .htaccess and etc. + Allow []string + // Always specifies list of extensions which must always be served by static // service, even if file not found. Always []string @@ -48,29 +50,3 @@ func (c *Config) Valid() error { return nil } - -// 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.Static.Forbid { - if ext == v { - return true - } - } - - 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.Static.Always { - if ext == v { - return true - } - } - - return false -} |