From de75af9fe2d91df7297e498d320b496addfb52f4 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Thu, 1 May 2014 16:10:20 -0700 Subject: [PATCH] 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 (github: shykes) --- engine/engine.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/engine/engine.go b/engine/engine.go index dc1984ccb5..6f80e54b7e 100644 --- a/engine/engine.go +++ b/engine/engine.go @@ -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 }