コード例 #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            //if (env.IsDevelopment())
            //{
            //    app.UseDeveloperExceptionPage();
            //}
            //else
            //{
            //    app.UseExceptionHandler("/Error");
            //}

            //app.UseStaticFiles();

            //app.UseRouting();

            //app.UseAuthorization();

            //app.UseEndpoints(endpoints =>
            //{
            //    endpoints.MapRazorPages();
            //});
            app.Run(async context =>
            {
                if (context.Request.Query.ContainsKey("ui"))
                {
                    var tag = context.Request.Query["ui"];
                    CultureInfo.CurrentUICulture = new CultureInfo(tag);
                }
                if (context.Request.Query.ContainsKey("about"))
                {
                    var searchTerm        = context.Request.Query["about"];
                    IAboutService service = context.RequestServices.GetService <IAboutService>();
                    var content           = service.Reply(searchTerm);
                    await context.Response.WriteAsync(content);
                    return;
                }

                if (context.Request.Query.ContainsKey("help"))
                {
                    string serviceName   = context.Request.Query["help"];
                    IHelpService service = context.RequestServices.GetService <IHelpService>();

                    var content = service.GetHelpFor(serviceName);
                    await context.Response.WriteAsync(content);

                    return;
                }

                if (context.Request.Query.ContainsKey("department"))
                {
                    var department = context.Request.Query["department"];

                    IDepartmentService service = context.RequestServices.GetService <IDepartmentService>();
                    var info = service.GetInfo(department);

                    await context.Response.WriteAsync(info);

                    return;
                }

                await context.Response.WriteAsync("Welcome to App-O-Matic");
            });
        }