From 7da6c78449776e1f3c6716250bca0b712a0423a4 Mon Sep 17 00:00:00 2001 From: Valery Piashchynski Date: Thu, 21 Jan 2021 13:25:36 +0300 Subject: Uniform all configs Add debug server Check nil's for all plugin intialization --- plugins/static/config.go | 2 +- plugins/static/plugin.go | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'plugins/static') diff --git a/plugins/static/config.go b/plugins/static/config.go index 17a82cfd..90efea76 100644 --- a/plugins/static/config.go +++ b/plugins/static/config.go @@ -10,7 +10,7 @@ import ( // Config describes file location and controls access to them. type Config struct { - Static struct { + Static *struct { // Dir contains name of directory to control access to. Dir string diff --git a/plugins/static/plugin.go b/plugins/static/plugin.go index 6331037c..fa2bcfbe 100644 --- a/plugins/static/plugin.go +++ b/plugins/static/plugin.go @@ -29,11 +29,18 @@ type Plugin struct { // misconfiguration. Services must not be used without proper configuration pushed first. func (s *Plugin) Init(cfg config.Configurer, log logger.Logger) error { const op = errors.Op("static_plugin_init") + if !cfg.Has(RootPluginName) { + return errors.E(op, errors.Disabled) + } err := cfg.UnmarshalKey(RootPluginName, &s.cfg) if err != nil { return errors.E(op, errors.Disabled, err) } + if s.cfg.Static == nil { + return errors.E(op, errors.Disabled) + } + s.log = log s.root = http.Dir(s.cfg.Static.Dir) -- cgit v1.2.3