Beispiel #1
0
        public void ConfigureServices(IServiceCollection services)
        {
            services
            .AddEntityFrameworkNpgsql()
            .AddDbContext <SwitchmasterDbContext>(options =>
            {
                options.UseNpgsql(_configuration.GetConnectionString("DefaultConnection"));
            });

            services
            .AddMvc()
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            services.AddSignalR();

            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/dist";
            });

            var nexusConfig = new NexusConfiguration();

            _configuration.Bind("Nexus", nexusConfig);
            services.AddSingleton(nexusConfig);
            services.AddSingleton <NexusClient>();
        }
Beispiel #2
0
        public NexusClient(NexusConfiguration config)
        {
            _apiRoot = config.ApiRoot;
            _client  = new HttpClient();
            var encodedCredentials = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{config.Username}:{config.Password}"));

            _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", encodedCredentials);
        }