Browse code

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)

Solomon Hykes authored on 2014/05/02 08:10:20
Showing 1 changed files
... ...
@@ -118,13 +118,12 @@ func (eng *Engine) Job(name string, args ...string) *Job {
118 118
 	if eng.Logging {
119 119
 		job.Stderr.Add(utils.NopWriteCloser(eng.Stderr))
120 120
 	}
121
-	if eng.catchall != nil {
121
+
122
+	// Catchall is shadowed by specific Register.
123
+	if handler, exists := eng.handlers[name]; exists {
124
+		job.handler = handler
125
+	} else if eng.catchall != nil {
122 126
 		job.handler = eng.catchall
123
-	} else {
124
-		handler, exists := eng.handlers[name]
125
-		if exists {
126
-			job.handler = handler
127
-		}
128 127
 	}
129 128
 	return job
130 129
 }