コード例 #1
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to add services to the container.
        /// </summary>
        /// <param name="services"></param>
        public void ConfigureServices(IServiceCollection services)
        {
            DatabaseSetup.AddDatabaseSetup(services, Configuration);
            IdentitySetup.AddIdentitySetup(services, Configuration);
            AuthenticationJwtSetup.AddAuthenticationJwtSetup(services, Configuration);
            AutoMapperSetup.AddAutoMapperSetup(services);
            DependencyInjectionSetup.AddDependencyInjectionSetup(services);
            SwaggerSetup.AddSwaggerSetup(services);

            // Determinar que a api vai chamar uma determinada controller
            services.AddMvc(options =>
            {
                // configuração que obrigar que seja informado uma autenticação
                // garante que todas as requests sejam autenticadas
                var policy = new AuthorizationPolicyBuilder()
                             .RequireAuthenticatedUser()
                             .Build();

                options.Filters.Add(new AuthorizeFilter(policy));
            })
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
            // Configuração para não retorna referencia cicular no json
            .AddJsonOptions(options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);

            services.AddCors();
        }
コード例 #2
0
ファイル: Startup.cs プロジェクト: cebellincanta/CrmallTeste
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddSingleton(Configuration);
     AutoMapperSetup.AddAutoMapperSetup(services);
     SwaggerSetup.AddSwaggerSetup(services);
     DependencyInjectionSetup.AddDependencyInjectionSetup(services, Configuration);
     ApiSetup.AddApiSetup(services, Configuration);
 }