Commit ba88be0f authored by Matthew Holt's avatar Matthew Holt

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.
parent 8471c2d9
...@@ -8,12 +8,14 @@ import ( ...@@ -8,12 +8,14 @@ import (
// dispenser is a type that gets exposed to middleware // dispenser is a type that gets exposed to middleware
// generators so that they can parse tokens to configure // generators so that they can parse tokens to configure
// their instance. // 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 { type dispenser struct {
parser *parser parser *parser
cursor int cursor int
nesting int nesting int
tokens []token tokens []token
//err error
} }
// newDispenser returns a new dispenser. // newDispenser returns a new dispenser.
......
...@@ -113,7 +113,9 @@ func (p *parser) unwrap() error { ...@@ -113,7 +113,9 @@ func (p *parser) unwrap() error {
if err != nil { if err != nil {
return err return err
} }
p.cfg.Middleware = append(p.cfg.Middleware, mid) if mid != nil {
p.cfg.Middleware = append(p.cfg.Middleware, mid)
}
} else { } else {
return errors.New("No middleware bound to directive '" + directive + "'") return errors.New("No middleware bound to directive '" + directive + "'")
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment