engine: catchall handler is shadowed by specific handlers

This allows using `Engine.Register` and `Engine.RegisterCatchall` on the
same engine without the catchall hiding all other handlers.

Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
This commit is contained in:
Solomon Hykes 2014-05-01 16:10:20 -07:00
parent 103d028132
commit de75af9fe2
1 changed files with 5 additions and 6 deletions

View File

@ -118,13 +118,12 @@ func (eng *Engine) Job(name string, args ...string) *Job {
if eng.Logging {
job.Stderr.Add(utils.NopWriteCloser(eng.Stderr))
}
if eng.catchall != nil {
// Catchall is shadowed by specific Register.
if handler, exists := eng.handlers[name]; exists {
job.handler = handler
} else if eng.catchall != nil {
job.handler = eng.catchall
} else {
handler, exists := eng.handlers[name]
if exists {
job.handler = handler
}
}
return job
}