// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IDefaultResponse defaultResponse, ILogger <Startup> logger) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler(); } //app.UseDefaultFiles(); //app.UseDefaultFiles(new DefaultFilesOptions { DefaultFileNames = new List<string>() { "boat.html" } }); //app.UseFileServer(); app.UseStaticFiles(); //app.UseMvcWithDefaultRoute(); app.UseMvc(ConfigureRoutes); //Custom Middleware //app.Use(next => //{ // return async context => // { // logger.LogInformation("1-Request arriving"); // if (context.Request.Path.StartsWithSegments("/cmf")) // { // await context.Response.WriteAsync("Custom Middleware Func<>!"); // logger.LogInformation("2-Request fired."); // logger.LogInformation("3-Response with custom Middleware!"); // } // else // { // await next(context); // logger.LogInformation("3-Response without custom Middleware!"); // } // }; //}); //app.UseWelcomePage(new WelcomePageOptions { // Path = "/welcome" //}); app.Run(async(context) => { //throw new Exception(); //var defaultResponseMessage = defaultResponse.GetDefaultReponseHardCoded(); //var defaultResponseMessage = defaultResponse.GetDefaultResponse(); var defaultResponseMessage = "NotFound!"; context.Response.ContentType = "text/plain"; await context.Response.WriteAsync($"{defaultResponseMessage}"); //await context.Response.WriteAsync($"{defaultResponseMessage} [{env.EnvironmentName}]"); }); }
public HomeController(IRestaurantData restaurantData, IDefaultResponse defaultResponse) { _restaurantData = restaurantData; _defaultResponse = defaultResponse; }
public DefaultResponse(IDefaultResponse defaultResponse) { _defaultResponse = defaultResponse; }