mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-01 00:23:48 +03:00
Allow nil middleware to be returned
In case a middleware actually just wants some code to execute at startup... will expand on that idea later.
This commit is contained in:
parent
8471c2d9d8
commit
ba88be0fe9
2 changed files with 6 additions and 2 deletions
|
@ -8,12 +8,14 @@ import (
|
|||
// dispenser is a type that gets exposed to middleware
|
||||
// generators so that they can parse tokens to configure
|
||||
// their instance.
|
||||
// TODO: Rename this; it does more than dispense tokens.
|
||||
// It also provides access to the server to touch its
|
||||
// configuration.
|
||||
type dispenser struct {
|
||||
parser *parser
|
||||
cursor int
|
||||
nesting int
|
||||
tokens []token
|
||||
//err error
|
||||
}
|
||||
|
||||
// newDispenser returns a new dispenser.
|
||||
|
|
|
@ -113,7 +113,9 @@ func (p *parser) unwrap() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
p.cfg.Middleware = append(p.cfg.Middleware, mid)
|
||||
if mid != nil {
|
||||
p.cfg.Middleware = append(p.cfg.Middleware, mid)
|
||||
}
|
||||
} else {
|
||||
return errors.New("No middleware bound to directive '" + directive + "'")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue