예제 #1
0
        // 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, IMongoDbManager manager)
        {
            _manager = manager;

            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            var logger = loggerFactory.CreateLogger("Configure Endpoint");

            logger.LogDebug("Server Configured......");

            //app.UseIISPlatformHandler();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();

                app.UseBrowserLink();

                _manager.Connect("mongodb://localhost:27017");
                _manager.SetDatabase("music-storedb");
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }


            app.UseDefaultFiles();
            app.UseStaticFiles();

            app.Use(async(context, next) =>
            {
                await next();

                if (context.Response.StatusCode == 404)
                {
                    context.Request.Path = "/index.html"; // Put your Angular root page here
                    await next();
                }
            });

            app.UseMvcWithDefaultRoute();
            app.UseMvc();
        }
 protected MongoBaseRepository(IMongoDbManager dbManager)
 {
     _mongoDbManager = dbManager;
     dbManager.Connect("mongodb://localhost:27017");
     dbManager.SetDatabase("blood-floaterdb");
 }
예제 #3
0
        // 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, IMongoDbManager manager)
        {
            _mongoDbManager = manager;

            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            var logger = loggerFactory.CreateLogger("Configure Endpoint");

            logger.LogDebug("Server Configured......");

            // this will serve up wwwroot
            app.UseDefaultFiles();
            app.UseStaticFiles();

            AutoMapperConfiguration.Configure();

            //app.UseCors("AllowSpecificOrigin");

            var jwtAppSettingOptions      = Configuration.GetSection(nameof(JwtIssuerOptions));
            var tokenValidationParameters = new TokenValidationParameters
            {
                ValidateIssuer = true,
                ValidIssuer    = jwtAppSettingOptions[nameof(JwtIssuerOptions.Issuer)],

                ValidateAudience = true,
                ValidAudience    = jwtAppSettingOptions[nameof(JwtIssuerOptions.Audience)],

                ValidateIssuerSigningKey = true,
                IssuerSigningKey         = _signingKey,

                RequireExpirationTime = true,
                ValidateLifetime      = true,

                ClockSkew = TimeSpan.FromMinutes(0)
            };

            app.UseJwtBearerAuthentication(new JwtBearerOptions
            {
                AutomaticAuthenticate     = true,
                AutomaticChallenge        = true,
                TokenValidationParameters = tokenValidationParameters
            });

            app.UseDeveloperExceptionPage();

            // Custom authentication middleware
            //app.UseMiddleware<AuthMiddleware>();
            if (env.IsDevelopment())
            {
                app.UseBrowserLink();

                _mongoDbManager.Connect("mongodb://localhost:27017");
                _mongoDbManager.SetDatabase("blood-floaterdb");
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseCors("CorsPolicy");

            app.UseMvcWithDefaultRoute();
            // Add MVC to the request pipeline.
            app.UseMvc();

            DbInitializer.Initialize(app.ApplicationServices, _applicationPath);
        }
예제 #4
0
 protected BaseService(IMongoDbManager dbManager)
 {
     dbManager.Connect("mongodb://localhost:27017");
     dbManager.SetDatabase("music-storedb");
 }