Ejemplo n.º 1
0
 public void StartServer(int port, IRobot robo, Action<IAppBuilder> app)
 {
     robo.Log.Info("Sharpening the Katana on port {0}...", port);
     var settings = new KatanaSettings()
     {
         DefaultPort = port,
         LoaderFactory = () => _ => app
     };
     var engine = new KatanaEngine(settings);
     engine.Start(new StartContext());
     robo.Log.Info("Katana is listening on port {0}", port);
 }
Ejemplo n.º 2
0
        public EmbeddedFubuMvcServer(FubuRuntime runtime, string physicalPath = null, int port = 5500, StartParameters parameters = null)
        {
            _runtime = runtime;

            parameters      = parameters ?? new StartParameters();
            parameters.Port = port;

            FubuMvcPackageFacility.PhysicalRootPath = physicalPath ?? AppDomain.CurrentDomain.BaseDirectory;

            //_server = WebApplication.Start<Starter>(port: port, verbosity: 1);

            var context = new StartContext
            {
                Parameters = parameters,
            };

            var settings = new KatanaSettings
            {
                LoaderFactory = () => (s => builder => {
                    var host = new FubuOwinHost(_runtime.Routes);
                    builder.Run(host);
                }),
            };

            var engine = new KatanaEngine(settings);

            _server = engine.Start(context);

            _baseAddress = "http://localhost:" + port;

            _urls = _runtime.Factory.Get <IUrlRegistry>();
            _urls.As <UrlRegistry>().RootAt(_baseAddress);

            UrlContext.Stub(_baseAddress);

            _services  = _runtime.Factory.Get <IServiceLocator>();
            _endpoints = new EndpointDriver(_urls);
        }