public static void Setup(TestContext ctx)
 {
     IntegrationTestManager.Startup(c => {
         ApiVersioning.Configure(c)
         .ConfigureRequestVersionDetector <DefaultRouteKeyVersionDetector>();
     });
 }
コード例 #2
0
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            config.EnableCors(new EnableCorsAttribute(ConfigurationManager.AppSettings["webapp"], "*", "PUT, HEAD, OPTIONS, GET, POST, DELETE"));

            var dependencyContainer = new TinyIoCContainer();

            // API VERSIONING
            // [email protected]:Sebazzz/SDammann.WebApi.Versioning.git Commit: 08ec8ed339b564996743ad0fff13953fe1e95b33
            config.Services.Replace(typeof(IHttpControllerSelector), new MyVersionedApiControllerSelector(config));
            config.Services.Replace(typeof(IApiExplorer), new VersionedApiExplorer(config));
            config.DependencyResolver = new DependencyResolver(dependencyContainer);

            dependencyContainer.Register((c, np) => new DefaultControllerIdentificationDetector(config));
            dependencyContainer.Register((c, np) => new DefaultRequestControllerIdentificationDetector(config));

            RegisterServices(dependencyContainer);
            RegisterControllers(dependencyContainer);

            ApiVersioning.Configure()
            .ConfigureRequestVersionDetector <DefaultRouteKeyVersionDetector>();

            // Web API routes
            config.MapHttpAttributeRoutes();
            ConfigParameterBindings(config);
            ConfigApiRoutes(config);
            ConfigFilters(config);
        }
コード例 #3
0
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services
            config.SetDocumentationProvider(
                new XmlDocumentationProvider(
                    HostingEnvironment.MapPath("~/bin/" + typeof(WebApiConfig).Assembly.GetName().Name + ".xml")));

            var dependencyContainer = new TinyIoCContainer();

            // API versioning
            config.Services.Replace(typeof(IHttpControllerSelector), new VersionedApiControllerSelector(config));
            config.Services.Replace(typeof(IApiExplorer), new VersionedApiExplorer(config));
            config.DependencyResolver = new DependencyResolver(dependencyContainer);

            dependencyContainer.Register((c, np) => new DefaultControllerIdentificationDetector(config));
            dependencyContainer.Register((c, np) => new DefaultRequestControllerIdentificationDetector(config));

            ApiVersioning.Configure(config)
            .ConfigureRequestVersionDetector <DefaultRouteKeyVersionDetector>();

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute("DefaultApi", "api/v{version}/{controller}/{id}", new { id = RouteParameter.Optional });
        }
コード例 #4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            var connectionString = Configuration.GetConnectionString("Default");

            Dependency.SetDependency(ref services, connectionString);
            services.AddSingleton(AutoMapperConfig.Config());

            ApiVersioning.SetVersion(ref services);
        }
コード例 #5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            var virusTotalUrl    = Configuration.GetSection("VirusTotal:Url").Get <string>();
            var virusTotalApiKey = Configuration.GetSection("VirusTotal:ApiKey").Get <string>();

            Dependency.SetDependency(ref services, virusTotalUrl, virusTotalApiKey);
            services.AddSingleton(AutoMapperConfig.Config());
            ApiVersioning.SetVersion(ref services);
        }
コード例 #6
0
 public static void ConfigureServices(IConfiguration configuration, IServiceCollection services)
 {
     Mvc.ConfigureService(configuration, services);
     Swagger.ConfigureService(configuration, services);
     ApiVersioning.ConfigureService(services);
     services.AddAutoMapper();
     AplicacaoConfiguracao.ConfigureService(configuration, services);
     Repositories.ConfigureService(services);
     ApiServices.ConfigureService(services);
 }
コード例 #7
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            var acountId   = Configuration.GetSection("MaxMind:AcountId").Get <int>();
            var licenseKey = Configuration.GetSection("MaxMind:LicenseKey").Get <string>();

            Dependency.SetDependency(ref services, acountId, licenseKey);
            services.AddSingleton(AutoMapperConfig.Config());

            ApiVersioning.SetVersion(ref services);
        }
コード例 #8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            var internalDomainCheckUrl           = Configuration.GetSection("InternalDomainCheckUrl").Get <string>();
            var internalVirusTotalIntegrationUrl = Configuration.GetSection("InternalVirusTotalIntegrationUrl").Get <string>();
            var internalOrderUrl = Configuration.GetSection("InternalOrderUrl").Get <string>();

            Dependency.SetDependency(ref services, internalDomainCheckUrl, internalOrderUrl, internalVirusTotalIntegrationUrl);
            services.AddSingleton(AutoMapperConfig.Config());

            ApiVersioning.SetVersion(ref services);
        }
コード例 #9
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var jwtTokenSettings   = Configuration.GetSection("JwtTokenSettings").Get <JwtTokenSettings>();
            var jwtTokenValidation = Configuration.GetSection("JwtTokenValidation").Get <JwtTokenValidation>();
            var allowedOrigins     = Configuration.GetSection("AllowedOrigins").Get <string[]>();

            services.AddControllers();

            services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(options =>
            {
                options.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuer           = true,
                    ValidateAudience         = true,
                    ValidateLifetime         = true,
                    ValidateIssuerSigningKey = true,

                    ValidIssuer      = jwtTokenValidation.ValidIssuer,
                    ValidAudience    = jwtTokenValidation.ValidAudience,
                    IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtTokenValidation.IssuerSigningKey)),
                    ClockSkew        = jwtTokenValidation.ClockSkew
                };
            });

            services.AddCors(options =>
            {
                options.AddPolicy("CORS", corsPolicyBuilder => corsPolicyBuilder
                                  .AllowAnyMethod()
                                  .AllowAnyHeader()
                                  .WithOrigins(allowedOrigins)
                                  .AllowCredentials());
            });

            var connectionString = Configuration.GetConnectionString("Default");

            Dependency.SetDependency(ref services, connectionString, jwtTokenSettings, jwtTokenValidation);

            services.AddSingleton(Helper.AutoMapper.Config());

            ApiVersioning.SetVersion(ref services);
        }
コード例 #10
0
        public void ConfigureServices(IServiceCollection services)
        {
            var allowedOrigins   = Configuration.GetSection("AllowedOrigins").Get <string[]>();
            var connectionString = Configuration.GetConnectionString("Default");

            services.AddControllers();

            services.AddCors(options =>
            {
                options.AddPolicy("CORS", corsPolicyBuilder => corsPolicyBuilder
                                  .AllowAnyMethod()
                                  .AllowAnyHeader()
                                  .WithOrigins(allowedOrigins)
                                  .AllowCredentials());
            });
            Dependency.SetDependency(ref services, connectionString);
            services.AddSingleton(Helper.AutoMapper.Config());

            ApiVersioning.SetVersion(ref services);
        }
コード例 #11
0
        public static void Register(HttpConfiguration config)
        {
            //Cors
            config.EnableCors();

            //Formaters
            config.Formatters.Add(new CsvFormatter(new QueryStringMapping("format", "csv", "text/csv")));
            //config.Formatters.Add(new XmlFormatter(new QueryStringMapping("format", "xml", "application/xml")));

            var dependencyContainer = new TinyIoCContainer();

            //// API versioning
            config.Services.Replace(typeof(IHttpControllerSelector), new VersionedApiControllerSelector(config));
            config.Services.Replace(typeof(IApiExplorer), new VersionedApiExplorer(config));
            config.DependencyResolver = new DependencyResolver(dependencyContainer);

            dependencyContainer.Register((c, np) => new DefaultControllerIdentificationDetector(config));
            dependencyContainer.Register((c, np) => new DefaultRequestControllerIdentificationDetector(config));

            ApiVersioning.Configure(config).ConfigureRequestVersionDetector <DefaultRouteKeyVersionDetector>();

            //// Web API routes
            config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute("DefaultApi", "v{version}/{controller}/{id}",
                                       new { id = RouteParameter.Optional });
            config.Routes.MapHttpRoute("Error404", "{*url}", new { controller = "Error", action = "Handle404" });
            config.Routes.MapHttpRoute("Error405", "{*url}", new { controller = "Error", action = "Handle405" });

            //Services
            config.Services.Replace(typeof(IExceptionHandler), new GlobalExceptionHandler());
            //config.Services.Replace(typeof(IHttpControllerSelector), new HttpNotFoundAwareDefaultHttpControllerSelector(config));
            //config.Services.Replace(typeof(IHttpActionSelector), new HttpNotFoundAwareControllerActionSelector());

            //Handlers
            config.MessageHandlers.Add(new LanguageNegotiationHandler());
            config.MessageHandlers.Add(new UniqueRequestIdentifierHandler());
            config.MessageHandlers.Add(new ResourceOptionsHandler());
            config.MessageHandlers.Add(new CompressionNegotiationHandler());

            FilterConfig.RegisterHttpFilters(config.Filters);
        }
コード例 #12
0
 public static void Convention(ApiVersioningOptions options)
 {
     options.Conventions.Controller <VideoController>().HasApiVersions(ApiVersioning.Versions());
 }