// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddTransient <IStatisticService, StatisticService>(); services.AddTransient <ILeagueTableService, LeagueTableService>(); services.AddTransient <IMatchService, MatchService>(); services.AddTransient <IPlayerService, PlayerService>(); services.AddTransient <ITeamService, TeamService>(); services.AddTransient <ILeagueService, LeagueService>(); services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddTransient <IAccountService, AccountService>(); services.AddTransient <IConfigurationService, ConfigurationService>(); services.AddSingleton(AutoMapperConfig.Initialize()); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" }); }); services.AddCors(options => options.AddPolicy("CorsPolicy", builder => { builder.AllowAnyHeader(); builder.AllowAnyMethod(); builder.AllowAnyOrigin(); builder.AllowCredentials(); })); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); PassedConfig.Config(Configuration, services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { PassedConfig.Config(this.Configuration, services); services.AddTransient <IUserService, UserService>(); services.AddTransient <IConfigurationService, ConfigurationService>(); services.AddTransient <ILanguageService, LanguageService>(); services.AddTransient <IScriptService, ScriptService>(); services.AddTransient <IRobotService, RobotService>(); JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); services .AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(cfg => { cfg.RequireHttpsMetadata = false; cfg.SaveToken = true; cfg.TokenValidationParameters = new TokenValidationParameters { ValidateAudience = false, ValidateIssuer = false, ValidIssuer = Configuration["Jwt:Issuer"], ValidAudience = Configuration["Jwt:Issuer"], IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["Jwt:Key"])), ValidateLifetime = true, ClockSkew = TimeSpan.Zero }; }); services.AddCors(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "You api title", Version = "v1" }); c.AddSecurityDefinition("Bearer", new ApiKeyScheme { In = "header", Description = "Please enter JWT with Bearer into field", Name = "Authorization", Type = "apiKey" }); c.AddSecurityRequirement(new Dictionary <string, IEnumerable <string> > { { "Bearer", Enumerable.Empty <string>() }, }); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { PassedConfig.Config(this.Configuration, services); services.AddTransient <ITeamService, TeamService>(); services.AddCors(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddSignalR(); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" }); }); }