Skip to content

Instantly share code, notes, and snippets.

@marfarma
Created July 15, 2013 19:43
Show Gist options
  • Save marfarma/6002805 to your computer and use it in GitHub Desktop.
Save marfarma/6002805 to your computer and use it in GitHub Desktop.
// // public overload of ServiceStackHttpHandlerFactory.GetCatchAllHandlerIfAny, adds function parameter, for CatchAllHandlers the want to // all other CatchAllHandlers to have precedence. Prevents infinite recursion //
//
// public overload of ServiceStackHttpHandlerFactory.GetCatchAllHandlerIfAny, adds function parameter, for CatchAllHandlers the want to
// all other CatchAllHandlers to have precedence. Prevents infinite recursion
//
public static IHttpHandler GetCatchAllHandlerIfAny(string httpMethod, string pathInfo, string filePath, function skipCatchAllHandler)
{
if (EndpointHost.CatchAllHandlers != null)
{
foreach (var httpHandlerResolver in EndpointHost.CatchAllHandlers)
{
if (httpHandlerResolver == skipCatchAllHandler) continue; // avoid infinite recursion
var httpHandler = httpHandlerResolver(httpMethod, pathInfo, filePath);
if (httpHandler != null)
return httpHandler;
}
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment