// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IHostingEnvironment env,
                              IGreetMessage greetMessage,
                              ILogger <Startup> logger)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            //app.UseMvcWithDefaultRoute();
            //default static page is index.html if nothing specified
            //app.UseDefaultFiles();
            //Allow serving up static files
            app.UseStaticFiles();

            //Add MVC with routs defined
            app.UseMvc(configureRoutes);


            app.Use(next =>
            {
                return(async context =>
                {
                    logger.LogInformation("Incoming request ");
                    if (context.Request.Path.StartsWithSegments("/mvm"))
                    {
                        await context.Response.WriteAsync("Hit my code in pipe line");
                    }
                    else
                    {
                        await next(context);
                        logger.LogInformation("response outgoing");
                    }
                });
            });

            app.UseWelcomePage(new WelcomePageOptions
            {
                Path = "/wp"
            });

            app.Run(async(context) =>
            {
                var greeting = _configuration["Greeting"];
                greeting     = greetMessage.getMessage();
                await context.Response.WriteAsync(greeting);
            });
        }
Beispiel #2
0
 public GreetService()
 {
     _greetMessage         = new GreetMessage();
     _greetShouttedMessage = new GreetShouttedMessage();
 }
Beispiel #3
0
 public HomeController(IRestaurantData restaurantData,
                       IGreetMessage greetMessage)
 {
     _restaurantData = restaurantData ?? throw new System.ArgumentNullException(nameof(restaurantData));
     _greetMessage   = greetMessage ?? throw new System.ArgumentNullException(nameof(greetMessage));
 }