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

Commit

Permalink
Made status code handler check break on first hit
Browse files Browse the repository at this point in the history
  • Loading branch information
khellang committed Aug 31, 2014
1 parent ab24dac commit 3370ee8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Nancy/NancyEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,15 @@ private void CheckStatusCodeHandler(NancyContext context)
return;
}

foreach (var statusCodeHandler in this.statusCodeHandlers)
var handler = this.statusCodeHandlers
.FirstOrDefault(x => x.HandlesStatusCode(context.Response.StatusCode, context));

if (handler == null)
{
if (statusCodeHandler.HandlesStatusCode(context.Response.StatusCode, context))
{
statusCodeHandler.Handle(context.Response.StatusCode, context);
}
return;
}

handler.Handle(context.Response.StatusCode, context);
}

private Task<NancyContext> InvokeRequestLifeCycle(NancyContext context, CancellationToken cancellationToken, IPipelines pipelines)
Expand Down

0 comments on commit 3370ee8

Please sign in to comment.