Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Commit

Permalink
Prioritize custom handler, fall back on DefaultStatusCodeHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
khellang committed Aug 31, 2014
1 parent 3370ee8 commit 7f57b20
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Nancy/NancyEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,17 @@ private void CheckStatusCodeHandler(NancyContext context)
return;
}

var handler = this.statusCodeHandlers
.FirstOrDefault(x => x.HandlesStatusCode(context.Response.StatusCode, context));
var handlers = this.statusCodeHandlers
.Where(x => x.HandlesStatusCode(context.Response.StatusCode, context))
.ToList();

var defaultHandler = handlers
.FirstOrDefault(x => x is DefaultStatusCodeHandler);

var customHandler = handlers
.FirstOrDefault(x => !(x is DefaultStatusCodeHandler));

var handler = customHandler ?? defaultHandler;
if (handler == null)
{
return;
Expand Down

0 comments on commit 7f57b20

Please sign in to comment.