// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure( IApplicationBuilder app, IHostingEnvironment env, ApplicationDbContext dbContext, RedisService redisService ) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseCors(options => { options.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); }); app.UseStaticFiles(); redisService.Connect(); // ===== Use Authentication ====== app.UseAuthentication(); app.UseMvcWithDefaultRoute(); app.UseSwagger(); app.UseSwaggerUI(opt => { opt.SwaggerEndpoint("/swagger/v1/swagger.json", "EzCRM_Api"); }); // ===== Create tables ====== dbContext.Database.EnsureCreated(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, RedisService redisService) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); redisService.Connect(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, RedisService redisService) { app.UseDeveloperExceptionPage(); app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("../swagger/v1/swagger.json", "BookRedis API V1"); c.RoutePrefix = string.Empty; }); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); redisService.Connect(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, RedisService redisService) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); redisService.Connect(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, RedisService redisService, IServiceProvider serviceProvider) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } //app.UseHttpsRedirection(); app.UseAuthentication(); app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); redisService.Connect(); redisService.upService(); app.UseStaticFiles(); // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "API Censo V1"); c.RoutePrefix = string.Empty; }); app.UseMvc(); }
private void Update() { if (redis.CurrConnectionStat == RedisService.ConnectionStat.None) { var config = ConfigurationOptions.Parse(server); redis.Connect(config); } }
private void OnEnable() { redis = new RedisService(); guiStopwatch = new System.Diagnostics.Stopwatch(); enabled = redis.Connect(server); var db = redis.GetDB(); db.StringSet("test_key", "test_val"); Debug.Log($"Get data : {db.StringGet("test_key")}"); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var requireAuthorizePolicy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Remove("sub"); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options => { options.Authority = Configuration["IdentityServerURL"]; options.Audience = "resource_basket"; options.RequireHttpsMetadata = false; }); services.AddHttpContextAccessor(); services.AddScoped <ISharedIdentityService, SharedIdentityService>(); services.AddScoped <IBasketService, BasketService>(); services.Configure <RedisSettings>(Configuration.GetSection("RedisSettings")); services.AddSingleton <RedisService>(sp => { var redisSettings = sp.GetRequiredService <IOptions <RedisSettings> >().Value; var redis = new RedisService(redisSettings.Host, redisSettings.Port); redis.Connect(); return(redis); }); services.AddControllers(opt => { opt.Filters.Add(new AuthorizeFilter(requireAuthorizePolicy)); }); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "Lms.Services.Basket", Version = "v1" }); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, RedisService redisService) { if (env.IsDevelopment()) { redisService.Connect(); app.UseDeveloperExceptionPage(); } // app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, RedisService redisService) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseSwagger(); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "MyAPI V1"); }); } else { app.UseHsts(); } app.UseCors("AllowAll"); app.UseHttpsRedirection(); redisService.Connect(); app.UseMvc(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, RedisService redisService) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } //app.UseCors(builder => builder.WithOrigins("http://localhost:3000").AllowAnyMethod().AllowAnyHeader()); // app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); app.UseCors("all"); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); redisService.Connect(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var requiredAuthorizePolicy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build(); JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Remove("sub");//sub ý maplerken ismini deðiþtirmesin diye ekledik //BasketApý'yi IdentityServer ile koruma altýna aldýk services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options => { options.Authority = Configuration["IdentityServerURL"]; options.Audience = "resource_basket"; options.RequireHttpsMetadata = false; }); services.AddHttpContextAccessor(); //Contexten user bilgisi alabilmek için eklendi services.AddScoped <ISharedIdentityService, SharedIdentityService>(); //Shared altýna tanýmladýðýmýz contexten user döndüren metodu kullanabilmek için ekledik services.AddScoped <IBasketService, BasketService>(); services.Configure <RedisSettings>(Configuration.GetSection("RedisSettings")); services.AddSingleton <RedisService>(sp => { var redisSettings = sp.GetRequiredService <IOptions <RedisSettings> >().Value; var redis = new RedisService(redisSettings.Host, redisSettings.Port); redis.Connect(); //Uygulama hayatta olduðu sürece bu baðlantý kurulacak return(redis); }); services.AddControllers(opt => { opt.Filters.Add(new AuthorizeFilter(requiredAuthorizePolicy)); //Artýk mutlaka sisteme kayýt olup giriþ yapmýþ kullanýcý bekliyoruz }); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = "FreeCourse.Service.Basket", Version = "v1" }); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, RedisService redisService) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); redisService.Connect(); app.UseEndpoints(endpoints => { endpoints.MapGrpcService <GreeterService>(); endpoints.MapGet("/", async context => { await context.Response.WriteAsync("Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909"); }); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, RedisService redisService) { app.UseCors("default"); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseDefaultFiles(); app.UseStaticFiles(); //app.UseHttpsRedirection(); //app.UseRouting(); //app.UseAuthorization(); // app.UseEndpoints(endpoints => // { // endpoints.MapControllers(); // }); app.UseMvc(); redisService.Connect(); }