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
| Get[@"/(?<foo>\d{2,4})/{bar}"] = parameters => { | |
| return View["viewname", parameters]; | |
| }; |
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
| Get[@"/(?<foo>\d{2,4})/{bar}", () => Request.Protocol.Equals("https")] = parameters => { | |
| return View["viewname", parameters]; | |
| }; |
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
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| var scheduler = | |
| new DefaultScheduler(); | |
| var host = new ServiceHost(scheduler, x => { | |
| x.JobRequestQueue = "foo"; | |
| x.TaskResponseQueue = "bar"; |
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
| namespace NancyConNegDemo | |
| { | |
| using Extensions; | |
| using Models; | |
| using Nancy; | |
| public class ConNegModule : NancyModule | |
| { | |
| public ConNegModule() : base("/conneg") | |
| { |
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 DefaultNancyModuleBuilders : INancyModuleBuilder | |
| { | |
| private readonly INancyModuleCatalog moduleCatalog; | |
| private readonly IViewFactory viewFactory; | |
| private readonly ResponseFormatter responseFormatter; | |
| public DefaultNancyModuleBuilders(INancyModuleCatalog moduleCatalog, IViewFactory viewFactory, ResponseFormatter responseFormatter) | |
| { | |
| this.moduleCatalog = moduleCatalog; | |
| this.viewFactory = viewFactory; |
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
| BeforeRequest += ctx => { | |
| var rootPathProvider = | |
| container.Resolve<IRootPathProvider>(); | |
| var staticFileExtensions = | |
| new Dictionary<string, string> | |
| { | |
| { "jpg", "image/jpg" }, | |
| { "png", "image/png" }, |
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
| private Tuple<long, long> GetNextBoundaryPositions() | |
| { | |
| var boundryMarkerSequence = new[] { (byte) '-', (byte) '-'}; | |
| var buffer = new byte[2]; | |
| var boundaryBuffer = new byte[Encoding.UTF8.GetBytes(this.boundary).Length]; | |
| while(true) | |
| { | |
| var numberOfBytesRead = | |
| this.requestStream.Read(buffer, 0, 2); |
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 Boundary | |
| { | |
| private readonly SubStream boundaryStream; | |
| private const byte LF = (byte)'\n'; | |
| private const byte CR = (byte)'\r'; | |
| public Boundary(SubStream boundaryStream) | |
| { | |
| this.boundaryStream = boundaryStream; | |
| this.ExtractHeaders(); |
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 RequestStream : Stream | |
| { | |
| private Stream stream; | |
| private readonly long expectedLength; | |
| private readonly long threshHoldLength; | |
| private bool disableStreamSwapping; | |
| public RequestStream(long expectedLength, long threshHoldLength, bool disableStreamSwapping) | |
| : this(null, expectedLength, threshHoldLength, disableStreamSwapping) | |
| { |
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
| /* | |
| * Conventions are maintained as Func<string, NancyModule, string> delegates | |
| * Bootstrapper lets you register these in a IList<Func<string, NancyModule, string>> which then goes into the container | |
| * Take a dependency on IEnumerable<Func<string, NancyModule, string>> when you need access to the delegates | |
| */ | |
| public interface IViewFactory | |
| { | |
| Action<Stream> RenderView(NancyModule module, string viewName, dynamic model); | |
| } |