Example #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,
                              IRequestHandler requestHandler,
                              IFactionAPIHandler factionAPIHandler)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            // Generate the Client Configuration settings from the HTTPProfile
            // and register the configuration with Faction
            factionAPIHandler.RegisterServerWithFactionAPI();

            // Get the http routes from the HttpProfile and register Get/Post routes
            var routeBuilder = new RouteBuilder(app);

            // // Map a Get and Post route
            // foreach (var route in State.Profile.Server.URLs)
            // {
            routeBuilder.MapGet("{Page=Home}", httpContext =>
            {
                return(requestHandler.Handle(httpContext));
            });

            routeBuilder.MapPost("{Page=Home}", httpContext =>
            {
                return(requestHandler.Handle(httpContext));
            });
            //}
            app.UseRouter(routeBuilder.Build());
            app.UseDefaultFiles();
            app.UseStaticFiles();
        }
 public RequestHandler(IFactionAPIHandler factionAPIHandler, IResponseHandler responseHandler)
 {
     _factionAPIHandler = factionAPIHandler;
     _responseHandler   = responseHandler;
 }