Example #1
0
 internal NancyHttpHost(Uri baseUri, PactConfig config, INancyBootstrapper bootstrapper)
 {
     _baseUri      = baseUri;
     _bootstrapper = bootstrapper;
     _log          = LogProvider.GetLogger(config.LoggerName);
     _config       = config;
 }
Example #2
0
 public WebServer(INancyBootstrapper bootstrapper)
 {
     _nancyHost = new NancyHost(new Uri("http://localhost:1234"), bootstrapper, new HostConfiguration
     {
         RewriteLocalhost = false
     });
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Browser"/> class.
 /// </summary>
 /// <param name="bootstrapper">A <see cref="INancyBootstrapper"/> instance that determines the Nancy configuration that should be used by the browser.</param>
 /// <param name="defaults">The default <see cref="BrowserContext"/> that should be used in a all requests through this browser object.</param>
 public Browser(INancyBootstrapper bootstrapper, Action<BrowserContext> defaults = null, bool initialiseBootstrapper = true)
 {
     this.bootstrapper = bootstrapper;
     if (initialiseBootstrapper) this.bootstrapper.Initialise();
     this.engine = this.bootstrapper.GetEngine();
     this.defaultBrowserContext = defaults ?? this.DefaultBrowserContext;
 }
Example #4
0
        public NancyOwinHostFixture()
        {
            this.fakeEngine = A.Fake <INancyEngine>();

            this.fakeBootstrapper = A.Fake <INancyBootstrapper>();
            A.CallTo(() => this.fakeBootstrapper.GetEngine()).Returns(this.fakeEngine);

            this.host = new NancyOwinHost(fakeBootstrapper);

            this.fakeResponseCallback = (status, headers, bodyDelegate) => { };

            this.fakeErrorCallback = (ex) => { };

            this.environment = new Dictionary <string, object>()
            {
                { "owin.RequestMethod", "GET" },
                { "owin.RequestPath", "/test" },
                { "owin.RequestPathBase", "/root" },
                { "owin.RequestQueryString", "var=value" },
                { "owin.RequestHeaders", new Dictionary <string, string>() },
                { "owin.RequestBody", null },
                { "owin.RequestScheme", "http" },
                { "owin.Version", "1.0" }
            };
        }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Browser"/> class.
 /// </summary>
 /// <param name="bootstrapper">A <see cref="INancyBootstrapper"/> instance that determines the Nancy configuration that should be used by the browser.</param>
 /// <param name="defaults">The default <see cref="BrowserContext"/> that should be used in a all requests through this browser object.</param>
 public Browser(INancyBootstrapper bootstrapper, Action <BrowserContext> defaults = null)
 {
     this.bootstrapper = bootstrapper;
     this.bootstrapper.Initialise();
     this.engine = this.bootstrapper.GetEngine();
     this.defaultBrowserContext = defaults ?? this.DefaultBrowserContext;
 }
Example #6
0
        public ViewBagTests()
        {
            this.bootstrapper = new ConfigurableBootstrapper(
                configuration => configuration.Modules(typeof(RazorTestModule)));

            this.browser = new Browser(bootstrapper);
        }
Example #7
0
        public module_tests_base()
        {
            AppDomainAssemblyTypeScanner.LoadAssemblies("*.dll");

            _bootstrapper = new ConfigurableBootstrapper(config => config.ViewFactory<TestingViewFactory>());
            _browser = new Browser(_bootstrapper);
        }
Example #8
0
        public NancyOwinHostFixture()
        {
            this.fakeEngine = A.Fake<INancyEngine>();

            this.fakeBootstrapper = A.Fake<INancyBootstrapper>();

            A.CallTo(() => this.fakeBootstrapper.GetEngine()).Returns(this.fakeEngine);

            this.host = new NancyOwinHost(fakeBootstrapper);

            this.fakeResponseCallback = (status, headers, bodyDelegate) => { };

            this.fakeErrorCallback = (ex) => { };

            this.environment = new Dictionary<string, object>()
                                   {
                                       { "owin.RequestMethod", "GET" },
                                       { "owin.RequestPath", "/test" },
                                       { "owin.RequestPathBase", "/root" },
                                       { "owin.RequestQueryString", "var=value" },
                                       { "owin.RequestHeaders", new Dictionary<string, string> { { "Host", "testserver" } } },
                                       { "owin.RequestBody", null },
                                       { "owin.RequestScheme", "http" },
                                       { "owin.Version", "1.0" }
                                   };
        }
        public NancyOwinHostFixture()
        {
            this.fakeEngine = A.Fake <INancyEngine>();

            this.fakeBootstrapper = A.Fake <INancyBootstrapper>();

            A.CallTo(() => this.fakeBootstrapper.GetEngine()).Returns(this.fakeEngine);

            this.host = new NancyOwinHost(fakeBootstrapper);

            this.fakeResponseCallback = (status, headers, bodyDelegate) => { };

            this.fakeErrorCallback = (ex) => { };

            var tcs = new TaskCompletionSource <object>();

            this.environment = new Dictionary <string, object>()
            {
                { "owin.RequestMethod", "GET" },
                { "owin.RequestPath", "/test" },
                { "owin.RequestPathBase", "/root" },
                { "owin.RequestQueryString", "var=value" },
                { "owin.RequestBody", Stream.Null },
                { "owin.RequestHeaders", new Dictionary <string, string[]>(StringComparer.OrdinalIgnoreCase) },
                { "owin.RequestScheme", "http" },
                { "owin.ResponseHeaders", new Dictionary <string, string[]>(StringComparer.OrdinalIgnoreCase) },
                { "owin.ResponseBody", Stream.Null },
                { "owin.Version", "1.0" },
                { "owin.CallCancelled", CancellationToken.None }
            };

            this.requestHeaders = new Dictionary <string, string[]> {
                { "Host", new[] { "testserver" } }
            };
        }
Example #10
0
        public TracingSmokeTests()
        {
            this.bootstrapper = new ConfigurableBootstrapper(
                    configuration => configuration.Modules(new Type[] { typeof(RazorWithTracingTestModule) }));

            this.browser = new Browser(bootstrapper);
        }
Example #11
0
        public ModelBindingFixture()
        {
            this.bootstrapper =
                new ConfigurableBootstrapper(with => with.Modules(new[] { typeof(ModelBindingModule), typeof(MixedSourceModelBindingModule) }));

            this.browser = new Browser(bootstrapper);
        }
Example #12
0
 internal NancyHttpHost(Uri baseUri, PactConfig config, INancyBootstrapper bootstrapper)
 {
     _baseUri = baseUri;
     _bootstrapper = bootstrapper;
     _log = LogProvider.GetLogger(config.LoggerName);
     _config = config;
 }
Example #13
0
        public module_tests_base()
        {
            AppDomainAssemblyTypeScanner.LoadAssemblies("*.dll");

            _bootstrapper = new ConfigurableBootstrapper(config => config.ViewFactory <TestingViewFactory>());
            _browser      = new Browser(_bootstrapper);
        }
Example #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Browser"/> class.
 /// </summary>
 /// <param name="bootstrapper">A <see cref="INancyBootstrapper"/> instance that determines the Nancy configuration that should be used by the browser.</param>
 /// <param name="defaults">The default <see cref="BrowserContext"/> that should be used in a all requests through this browser object.</param>
 public Browser(INancyBootstrapper bootstrapper, Action<BrowserContext> defaults = null)
 {
     this.bootstrapper = bootstrapper;
     this.bootstrapper.Initialise();
     this.engine = this.bootstrapper.GetEngine();
     this.defaultBrowserContext = defaults ?? DefaultBrowserContext;
 }
Example #15
0
        public NancyAdapter(AppFunc next, INancyBootstrapper bootstrapper)
        {
            bootstrapper.Initialise();

            _next   = next;
            _engine = bootstrapper.GetEngine();
        }
        public TracingSmokeTests()
        {
            this.bootstrapper = new ConfigurableBootstrapper(
                configuration => configuration.Modules(new Type[] { typeof(RazorWithTracingTestModule) }));

            this.browser = new Browser(bootstrapper);
        }
Example #17
0
        internal NancyHttpHost(Uri baseUri, string providerName, PactConfig config, bool bindOnAllAdapters)
        {
            var loggerName = LogProvider.CurrentLogProvider.AddLogger(config.LogDir, providerName.ToLowerSnakeCase(), "{0}_mock_service.log");

            config.LoggerName = loggerName;

            _baseUri      = baseUri;
            _bootstrapper = new MockProviderNancyBootstrapper(config);
            _log          = LogProvider.GetLogger(config.LoggerName);
            _config       = config;

            _nancyConfiguration = new HostConfiguration
            {
                AllowChunkedEncoding = false
            };

            if (bindOnAllAdapters)
            {
                _nancyConfiguration.UrlReservations = new UrlReservations
                {
                    CreateAutomatically = true
                };
                _nancyConfiguration.RewriteLocalhost = true;
            }
            else
            {
                _nancyConfiguration.RewriteLocalhost = false;
            }
        }
Example #18
0
        public ModelBindingFixture()
        {
            this.bootstrapper =
                new ConfigurableBootstrapper(with => with.Modules(new[] { typeof(ModelBindingModule), typeof(MixedSourceModelBindingModule) }));

            this.browser = new Browser(bootstrapper);
        }
Example #19
0
        public PartialViewTests()
        {
            this.bootstrapper = new ConfigurableBootstrapper(
                configuration => configuration.Modules(new [] { typeof(RazorTestModule) }));

            this.browser = new Browser(bootstrapper);
        }
Example #20
0
        public SerializeTests()
        {
            this.bootstrapper = new ConfigurableBootstrapper(
                    configuration => configuration.Modules(new Type[] { typeof(SerializeTestModule) }));

            this.browser = new Browser(bootstrapper);
        }
Example #21
0
        public SerializeTests()
        {
            this.bootstrapper = new ConfigurableBootstrapper(
                configuration => configuration.Modules(new Type[] { typeof(SerializeTestModule) }));

            this.browser = new Browser(bootstrapper);
        }
Example #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Browser"/> class.
 /// </summary>
 /// <param name="bootstrapper">A <see cref="INancyBootstrapper"/> instance that determines the Nancy configuration that should be used by the browser.</param>
 /// <param name="defaults">The default <see cref="BrowserContext"/> that should be used in a all requests through this browser object.</param>
 public Browser(INancyBootstrapper bootstrapper, Action <BrowserContext> defaults = null)
 {
     bootstrapper.Initialise();
     this.engine                = bootstrapper.GetEngine();
     this.environment           = bootstrapper.GetEnvironment();
     this.defaultBrowserContext = defaults ?? DefaultBrowserContext;
 }
Example #23
0
 public WebServer(INancyBootstrapper bootstrapper)
 {
     _nancyHost = new NancyHost(new Uri("http://localhost:1234"), bootstrapper, new HostConfiguration
     {
         RewriteLocalhost = false
     });
 }
Example #24
0
        public PartialViewTests()
        {
            this.bootstrapper = new ConfigurableBootstrapper(
                    configuration => configuration.Modules(new [] { typeof(RazorTestModule) }));

            this.browser = new Browser(bootstrapper);
        }
        public static NancyPack Use(this NancyPack pack, INancyBootstrapper bootstrapper)
        {
            Guard.AgainstNullArgument("pack", pack);

            pack.Boot = bootstrapper;
            return(pack);
        }
Example #26
0
        public ViewBagTests()
        {
            this.bootstrapper = new ConfigurableBootstrapper(
                    configuration => configuration.Modules(typeof(RazorTestModule)));

            this.browser = new Browser(bootstrapper);
        }
		public NancyEvent2Host(string host, int port, INancyBootstrapper bootstrapper)
		{
			_host = host;
			_port = port;
			_bootstrapper = bootstrapper;
			_bootstrapper.Initialise();
			_engine = _bootstrapper.GetEngine();
		}
Example #28
0
        public NancyHost(Uri baseUri, INancyBootstrapper bootStrapper)
        {
            this.baseUri = baseUri;
            listener = new HttpListener();
            listener.Prefixes.Add(baseUri.ToString());

            engine = bootStrapper.GetEngine();
        }
Example #29
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NancyHost"/> class for the specfied <paramref name="baseUris"/>, using
        /// the provided <paramref name="bootstrapper"/>.
        /// Uses the specified configuration.
        /// </summary>
        /// <param name="bootstrapper">The bootstrapper that should be used to handle the request.</param>
        /// <param name="configuration">Configuration to use</param>
        /// <param name="baseUris">The <see cref="Uri"/>s that the host will listen to.</param>
        public NancyHost(INancyBootstrapper bootstrapper, HostConfiguration configuration, params Uri[] baseUris)
        {
            this.configuration = configuration ?? new HostConfiguration();
            this.baseUriList   = baseUris;

            bootstrapper.Initialise();
            this.engine = bootstrapper.GetEngine();
        }
Example #30
0
#pragma warning disable S3994 // NOTE (Cameron): Represents an HTTP URL namespace and may not always be represented as a URI.
        public NancyWebApi(string apiUrl, INancyBootstrapper bootstrapper)
        {
            Guard.Against.Null(() => apiUrl);
            Guard.Against.Null(() => bootstrapper);

            this.apiUrl       = apiUrl;
            this.bootstrapper = bootstrapper;
        }
Example #31
0
 public CustomNancyHost(INancyBootstrapper bootstrapper, HostConfiguration configuration, params Uri[] baseUris)
 {
     _bootstrapper  = bootstrapper;
     _configuration = configuration ?? new HostConfiguration();
     _baseUriList   = baseUris;
     bootstrapper.Initialise();
     _engine = bootstrapper.GetEngine();
 }
Example #32
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NancyHost"/> class for the specfied <paramref name="baseUris"/>, using
        /// the provided <paramref name="bootstrapper"/>.
        /// Uses the specified configuration.
        /// </summary>
        /// <param name="bootstrapper">The bootstrapper that should be used to handle the request.</param>
        /// <param name="configuration">Configuration to use</param>
        /// <param name="baseUris">The <see cref="Uri"/>s that the host will listen to.</param>
        public NancyHost(INancyBootstrapper bootstrapper, HostConfiguration configuration, params Uri[] baseUris)
        {
            this.configuration = configuration ?? new HostConfiguration();
            this.baseUriList = baseUris;

            bootstrapper.Initialise();
            this.engine = bootstrapper.GetEngine();
        }
Example #33
0
 public HtmlExporter(string exportPath,
                     IConfiguration configuration,
                     INancyBootstrapper bootStrapper)
 {
     _configuration = configuration;
     _exportPath    = exportPath;
     _basePath      = Directory.GetCurrentDirectory();
     _bootStrapper  = bootStrapper;
 }
Example #34
0
        public OnResponseDataTests()
        {
            bootstrapper = new ConfigurableBootstrapper(with =>
            {
                with.Module<UsersModule>();
            });

            browser = new Browser(bootstrapper);
        }
Example #35
0
        public NancyEvent2Host(string host, int port, INancyBootstrapper bootstrapper, int workers)
        {
            _host = host;
            _port = port;
            _workers = workers;

            bootstrapper.Initialise();
            _engine = bootstrapper.GetEngine();
        }
Example #36
0
        public NancyHost(Uri baseUri, INancyBootstrapper bootStrapper)
        {
            this.baseUri = baseUri;
            listener     = new HttpListener();
            listener.Prefixes.Add(baseUri.ToString());

            bootStrapper.Initialise();
            engine = bootStrapper.GetEngine();
        }
Example #37
0
 public HtmlExporter(string exportPath,
     IConfiguration configuration,
     INancyBootstrapper bootStrapper)
 {
     _configuration = configuration;
     _exportPath = exportPath;
     _basePath = Directory.GetCurrentDirectory();
     _bootStrapper = bootStrapper;
 }
Example #38
0
 public HttpServer(ILogger<HttpServer> logger, INancyBootstrapper bootstrapper, IKeyValueStore keyValueStore)
 {
     if (logger == null) throw new ArgumentNullException("logger");
     if (bootstrapper == null) throw new ArgumentNullException("bootstrapper");
     if (keyValueStore == null) throw new ArgumentNullException("keyValueStore");
     _logger = logger;
     _bootstrapper = bootstrapper;
     _keyValueStore = keyValueStore;
 }
Example #39
0
        public NancyEvent2Host(string host, int port, INancyBootstrapper bootstrapper, int workers)
        {
            _host    = host;
            _port    = port;
            _workers = workers;

            bootstrapper.Initialise();
            _engine = bootstrapper.GetEngine();
        }
Example #40
0
        internal NancyHttpHost(Uri baseUri, string providerName, PactConfig config)
        {
            var loggerName = LogProvider.CurrentLogProvider.AddLogger(config.LogDir, providerName.ToLowerSnakeCase(), "{0}_mock_service.log");
            config.LoggerName = loggerName;

            _baseUri = baseUri;
            _bootstrapper = new MockProviderNancyBootstrapper(config);
            _log = LogProvider.GetLogger(config.LoggerName);
            _config = config;
        }
Example #41
0
        public JsonpTests()
        {
            this.bootstrapper = new ConfigurableBootstrapper(
                configuration =>
            {
                configuration.Modules(new Type[] { typeof(JsonpTestModule) });
            });

            this.browser = new Browser(bootstrapper);
        }
Example #42
0
        public TopService(INancyBootstrapper ninjectNancyBootstrapper, ServiceSettings serviceSettings, Logger logger, IScheduler scheduler)
        {
            _serviceSettings = serviceSettings;
            _ninjectNancyBootstrapper = ninjectNancyBootstrapper;
            _scheduler = scheduler;
            _logger = logger;

            logger.Info("Service was created with base url {0}", serviceSettings.BaseUrl);
            Trace.WriteLine("Service was created with base url: "+serviceSettings.BaseUrl);
        }
Example #43
0
        public StaticContentTests()
        {
            this.bootstrapper = new ConfigurableBootstrapper(
                    configuration =>
                        {
                            configuration.Modules(new Type[] { });
                        });

            this.browser = new Browser(bootstrapper);
        }
Example #44
0
        public StaticContentTests()
        {
            this.bootstrapper = new ConfigurableBootstrapper(
                configuration =>
            {
                configuration.Modules(new Type[] { });
            });

            this.browser = new Browser(bootstrapper);
        }
Example #45
0
        public OnRequestEmbeddedTests()
        {
            bootstrapper = new ConfigurableBootstrapper(with =>
            {
                with.Module<UsersModule>();
                with.Dependency<ISchemaConfiguration>(new SchemaConfiguration());
            });

            browser = new Browser(bootstrapper);
        }
Example #46
0
        public SchemaHandlerTests()
        {
            bootstrapper = new ConfigurableBootstrapper(with =>
            {
                with.Module<UsersModule>();
                with.Dependency<ISchemaHandler>(typeof(SchemaHandler));
            });

            browser = new Browser(bootstrapper);
        }
 private void RunServer(INancyBootstrapper nancyBootstrapper, HostConfiguration hostConfiguration)
 {
     var hostAddress = new Uri(HostAddress);
     m_NancyHost = new NancyHost(
         hostAddress,
         nancyBootstrapper,
         hostConfiguration
         );
     m_NancyHost.Start();
 }
Example #48
0
        public JsonpTests()
        {
            this.bootstrapper = new ConfigurableBootstrapper(
                    configuration =>
                        {
                            configuration.Modules(new Type[] { typeof(JsonpTestModule) });
                        });

            this.browser = new Browser(bootstrapper);
        }
Example #49
0
        internal NancyHttpHost(Uri baseUri, string providerName, PactConfig config)
        {
            var loggerName = LogProvider.CurrentLogProvider.AddLogger(config.LogDir, providerName.ToLowerSnakeCase(), "{0}_mock_service.log");

            config.LoggerName = loggerName;

            _baseUri      = baseUri;
            _bootstrapper = new MockProviderNancyBootstrapper(config);
            _log          = LogProvider.GetLogger(config.LoggerName);
            _config       = config;
        }
Example #50
0
        public WebServer(INancyBootstrapper webBootstrapper, IConfigManager configManager)
        {
            _webBootstrapper = webBootstrapper;
            _logger = Log.ForContext<WebServer>();

            BindInterface = configManager.WebServerConfig.BindInterface;
            Port = configManager.WebServerConfig.Port;

            if (configManager.WebServerConfig.Enabled)
                Start();
        }
        public ManualStaticContentTests()
        {
            this.bootstrapper = new ConfigurableBootstrapper(
                    configuration =>
                        {
                            configuration.ApplicationStartup((c, p) => StaticContent.Enable(p));
                            configuration.Modules(ArrayCache.Empty<Type>());
                        });

            this.browser = new Browser(bootstrapper);
        }
        public ManualStaticContentTests()
        {
            this.bootstrapper = new ConfigurableBootstrapper(
                configuration =>
            {
                configuration.ApplicationStartup((c, p) => StaticContent.Enable(p));
                configuration.Modules(new Type[] { });
            });

            this.browser = new Browser(bootstrapper);
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="nancyBootstrapper"></param>
 /// <param name="routeResolver"></param>
 /// <param name="pipeline"></param>
 /// <param name="cacheKeyGenerator"></param>
 /// <param name="cacheStore"></param>
 public static void Enable(INancyBootstrapper nancyBootstrapper, IRouteResolver routeResolver, IPipelines pipeline, ICacheKeyGenerator cacheKeyGenerator, ICacheStore cacheStore)
 {
     if (_enabled)
         return;
     _enabled = true;
     _cacheKeyGenerator = cacheKeyGenerator;
     _cacheStore = cacheStore;
     _nancyBootstrapper = nancyBootstrapper;
     _routeResolver = routeResolver;
     pipeline.BeforeRequest.AddItemToStartOfPipeline(CheckCache);
     pipeline.AfterRequest.AddItemToEndOfPipeline(SetCache);
 }
Example #54
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="nancyBootstrapper"></param>
 /// <param name="routeResolver"></param>
 /// <param name="pipeline"></param>
 /// <param name="varyParams"></param>
 /// <param name="cacheStore"></param>
 public static void Enable(INancyBootstrapper nancyBootstrapper, IRouteResolver routeResolver, IPipelines pipeline, IEnumerable<string> varyParams, ICacheStore cacheStore)
 {
     if (_enabled)
         return;
     _enabled = true;
     _varyParams = varyParams.Select(key => key.ToLower().Trim()).ToArray();
     _cacheStore = cacheStore;
     _nancyBootstrapper = nancyBootstrapper;
     _routeResolver = routeResolver;
     pipeline.BeforeRequest.AddItemToStartOfPipeline(CheckCache);
     pipeline.AfterRequest.AddItemToEndOfPipeline(SetCache);
 }
Example #55
0
 public RouteConstraintTests()
 {
     Invoked           = false;
     this.bootstrapper = new ConfigurableBootstrapper(
         configuration =>
     {
         configuration.ApplicationStartup((c, p) => { });
         configuration.Modules(new Type[] { typeof(RouteConstraintsModule) });
         configuration.RouteSegmentConstraints(new[] { typeof(UltimateRouteSegmentConstraint), typeof(VersionRouteSegmentConstraint) });
     });
     this.browser = new Browser(this.bootstrapper);
 }
        public void SetUp()
        {
            applicationSettingsMock = MockRepository.GenerateStrictMock <IApplicationSettings>();
            fileUploadHandlerMock   = MockRepository.GenerateStrictMock <IFileUploadHandler>();

            bootstrapper = new Bootstrapper(
                new TestBootstrapperConfiguration(
                    new InstanceRegistration[]
            {
                new InstanceRegistration(typeof(IApplicationSettings), applicationSettingsMock),
                new InstanceRegistration(typeof(IFileUploadHandler), fileUploadHandlerMock)
            }));
        }
Example #57
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NancyHost"/> class for the specfied <paramref name="baseUris"/>, using
        /// the provided <paramref name="bootstrapper"/>.
        /// </summary>
        /// <param name="bootstrapper">The boostrapper that should be used to handle the request.</param>
        /// <param name="baseUris">The <see cref="Uri"/>s that the host will listen to.</param>
        public NancyHost(INancyBootstrapper bootstrapper, params Uri[] baseUris)
        {
            baseUriList = baseUris;
            listener    = new HttpListener();

            foreach (var baseUri in baseUriList)
            {
                listener.Prefixes.Add(baseUri.ToString());
            }

            bootstrapper.Initialise();
            engine = bootstrapper.GetEngine();
        }
Example #58
0
        public WebServer(INancyBootstrapper webBootstrapper, IConfigManager configManager)
        {
            _webBootstrapper = webBootstrapper;
            _logger          = Log.ForContext <WebServer>();

            BindInterface = configManager.WebServerConfig.BindInterface;
            Port          = configManager.WebServerConfig.Port;

            if (configManager.WebServerConfig.Enabled)
            {
                Start();
            }
        }
Example #59
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NancyHost"/> class for the specfied <paramref name="baseUris"/>, using
        /// the provided <paramref name="bootstrapper"/>.
        /// </summary>
        /// <param name="bootstrapper">The boostrapper that should be used to handle the request.</param>
        /// <param name="baseUris">The <see cref="Uri"/>s that the host will listen to.</param>
        public NancyHost(INancyBootstrapper bootstrapper, params Uri[] baseUris)
        {
            baseUriList = baseUris;
            listener = new HttpListener();

            foreach (var baseUri in baseUriList)
            {
                listener.Prefixes.Add(baseUri.ToString().Replace("localhost", "+"));
            }

            bootstrapper.Initialise();
            engine = bootstrapper.GetEngine();
        }
Example #60
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="nancyBootstrapper"></param>
 /// <param name="routeResolver"></param>
 /// <param name="pipeline"></param>
 /// <param name="varyParams"></param>
 /// <param name="cacheStore"></param>
 public static void Enable(INancyBootstrapper nancyBootstrapper, IRouteResolver routeResolver, IPipelines pipeline, IEnumerable <string> varyParams, ICacheStore cacheStore)
 {
     if (_enabled)
     {
         return;
     }
     _enabled           = true;
     _varyParams        = varyParams.Select(key => key.ToLower().Trim()).ToArray();
     _cacheStore        = cacheStore;
     _nancyBootstrapper = nancyBootstrapper;
     _routeResolver     = routeResolver;
     pipeline.BeforeRequest.AddItemToStartOfPipeline(CheckCache);
     pipeline.AfterRequest.AddItemToEndOfPipeline(SetCache);
 }