Exemplo n.º 1
0
 ConfigServer()
 {
     _httpServer = new RestServer(
         new IPEndPoint(IPAddress.Parse(GetLocalIp()), DependencyConfiguration.DefaultPort),
         null,
         System.Reflection.Assembly.GetExecutingAssembly());
     _httpServer.RegisterRouteHandler(new RestServerServiceFileRouteHandler(DependencyConfiguration.DefaultBasePath));
 }
Exemplo n.º 2
0
        public RestServerHostedService(IOptions <RestServerHostedServiceConfiguration> configuration, ILogger <RestServerHostedService> logger)
        {
            _tokenSource = new CancellationTokenSource();
            _config      = configuration?.Value ?? throw new ArgumentNullException(nameof(configuration));
            _logger      = logger ?? throw new ArgumentNullException(nameof(logger));
            var loggerAdapter = new ILoggerAdapter(_logger);

            // initialize inversion of control container.
            _container = new RestServerContainer()
                         .WithSingleton(_config)
                         as RestServerContainer;

            // initialize simple rest server with config defaults.
            _restServer = new RestServer(
                _tokenSource.Token,
                new System.Net.IPEndPoint(System.Net.IPAddress.Any, _config.Port),
                _container,
                loggerAdapter,
                Assembly.GetAssembly(typeof(RestServerHostedService)));
            // register public file route
            _restServer.RegisterRouteHandler(new RestServerServiceFileRouteHandler("InetPub"));
        }