Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // JWT
            AddJwtAuthentication(services);

            // CORS
            services.AddCors();

            // NewtonJson
            services.AddControllers().AddNewtonsoftJson();

            // Swagger
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo
                {
                    Version     = "v1",
                    Title       = "MyShop.FileStore",
                    Description = "MyShop.FileStore Application",
                });
            });

            WebApiDIRegistration register = new WebApiDIRegistration(Configuration);

            register.RegisterAll(ref services);
        }
Exemplo n.º 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // JWT
            AddJwtAuthentication(services);

            // SignalR
            services.AddSignalR().AddJsonProtocol(options => {
                options.PayloadSerializerOptions.PropertyNamingPolicy = null;
            });

            // CORS
            services.AddCors(options =>
            {
                options.AddPolicy("AllowAllPolicy",
                                  builder =>
                {
                    builder
                    .WithOrigins(_webClientUrl)
                    .AllowAnyHeader()
                    .AllowAnyMethod()
                    .AllowCredentials();
                });
            });

            // NewtonJson
            services.AddControllers().AddNewtonsoftJson();

            // Swagger
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo
                {
                    Version     = "v1",
                    Title       = "SignalR-Best-Practice-API",
                    Description = "SignalR-Best-Practice Application",
                });
            });

            WebApiDIRegistration register = new WebApiDIRegistration(Configuration);

            register.RegisterAll(ref services);
        }