diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2019-03-31 20:41:29 -0600 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2019-03-31 20:41:29 -0600 |
commit | 6621406fa8b44826477ba7cbe2ff6c5462048f8e (patch) | |
tree | e06d9dcf413839ea4a3bbd78a783b56b3ba577f6 /caddy.go | |
parent | 27ff6aeccb99995880a86ee482dd90c1e5c85d85 (diff) |
Very basic middleware and route matching functionality
Diffstat (limited to 'caddy.go')
-rw-r--r-- | caddy.go | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -17,11 +17,7 @@ func Start(cfg Config) error { cfg.runners = make(map[string]Runner) for modName, rawMsg := range cfg.Modules { - mod, ok := modules[modName] - if !ok { - return fmt.Errorf("unrecognized module: %s", modName) - } - val, err := LoadModule(mod, rawMsg) + val, err := LoadModule(modName, rawMsg) if err != nil { return fmt.Errorf("loading module '%s': %v", modName, err) } @@ -68,14 +64,17 @@ type Config struct { type Duration time.Duration // UnmarshalJSON satisfies json.Unmarshaler. -func (d *Duration) UnmarshalJSON(b []byte) (err error) { +func (d *Duration) UnmarshalJSON(b []byte) error { dd, err := time.ParseDuration(strings.Trim(string(b), `"`)) + if err != nil { + return err + } cd := Duration(dd) d = &cd - return + return nil } // MarshalJSON satisfies json.Marshaler. -func (d Duration) MarshalJSON() (b []byte, err error) { +func (d Duration) MarshalJSON() ([]byte, error) { return []byte(fmt.Sprintf(`"%s"`, time.Duration(d).String())), nil } |