コード例 #1
0
 public ApiInfoController(IApiInfoService apiInfoService)
 {
     _apiInfoService = apiInfoService;
 }
コード例 #2
0
ファイル: Startup.cs プロジェクト: pbayarri/netcoreapipruebas
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IHateoasHelper hateoasHelper, IApiInfoService apiInfoService)
        {
            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();
            }

            var appSettingsSection = Configuration.GetSection("AppSettings");
            var appSettings        = appSettingsSection.Get <AppSettings>();

            app.AddCors(appSettings.CorsAllowedOrigins, appSettings.CorsAllowedMethods, appSettings.CorsAllowedHeaders);

            app.UseAuthentication();

            app.UseUIOfSwagger(appSettings.SwaggerEndPointJsonUrl, appSettings.SwaggerEndPointTitle);

            app.UseMiddleware <RequestResponseLoggingMiddleware>();
            app.UseMiddleware <ApiKeyMiddleware <User, ApiKey> >();
            loggerFactory.AddLog4Net();

            app.UseHttpsRedirection();
            app.UseMvc(b =>
            {
                b.Select().Expand().Filter().OrderBy().MaxTop(100).Count();
                b.MapODataServiceRoute("odata", "odata", GetEdmModel());
            });
            app.UseApiVersioning();

            // Inicializando los colaboradores para Hateoas según las APIs que hayamos configurado
            apiInfoService.GetAll().ToList().ForEach(installedApi => hateoasHelper.AddCollaborator(installedApi.ApiType, installedApi.BaseHref));
        }
コード例 #3
0
 public ApiInfoController(ILogger <ApiInfoController> logger,
                          IApiInfoService apiInfoService)
 {
     _logger         = logger ?? throw new ArgumentNullException(nameof(logger));
     _apiInfoService = apiInfoService ?? throw new ArgumentNullException(nameof(apiInfoService));
 }