示例#1
0
 public MarsRoverDbRepository(
     ILogger <MarsRoverDbRepository> logger,
     MarsRoverDbContext marsRoverDbContext
     )
 {
     _logger             = logger;
     _marsRoverDbContext = marsRoverDbContext;
 }
示例#2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IWebHostEnvironment env,
                              InitializationService initializationService,
                              MarsRoverDbContext marsRoverDbContext)
        {
            marsRoverDbContext.Database.Migrate();

            // Note: If we wanted to secure the API from only one origin do something similar to below code
            // app.UseCors(options => options
            //          .WithOrigins("http://localhost:4200")

            app.UseCors(options => options
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader()
                        );

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwagger();
                app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "MarsRoverApi v1"));
            }

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            // ***********************************
            // Initialize the photo data
            // ***********************************
            initializationService.Initialize();
        }