Created
November 20, 2013 19:51
-
-
Save thecodejunkie/7569861 to your computer and use it in GitHub Desktop.
Sample IResponseProcessor that enables you to return an ordinary response for text/html requests, using the Negotiator.WithMediaRangeModel method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ResponseResponseProcessor : IResponseProcessor | |
{ | |
public IEnumerable<Tuple<string, MediaRange>> ExtensionMappings | |
{ | |
get | |
{ | |
return Enumerable.Empty<Tuple<string, MediaRange>>(); | |
} | |
} | |
public ProcessorMatch CanProcess(MediaRange requestedMediaRange, dynamic model, NancyContext context) | |
{ | |
return new ProcessorMatch | |
{ | |
ModelResult = (model is Response) ? MatchResult.ExactMatch : MatchResult.NoMatch, | |
RequestedContentTypeResult = (requestedMediaRange == "text/html") ? MatchResult.ExactMatch : MatchResult.NoMatch | |
}; | |
} | |
public Response Process(MediaRange requestedMediaRange, dynamic model, NancyContext context) | |
{ | |
return (Response)model; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return Negotiator.WithMediaRangeModel("text/html", Response.Redirect("/")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment