Example #1
0
        /// <summary>
        /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        /// </summary>
        /// <param name="app"></param>
        /// <param name="env"></param>
        /// <param name="loggerFactory"></param>
        /// <param name="context"></param>
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, BatchServerContext context)
        {
            // Setup logging
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();
            var logger = loggerFactory.CreateLogger("GAB.BatchServer.API");

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

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

            if (Configuration.GetValue <bool>("BatchServer:RedirectToHttps"))
            {
                // Setup rewriting
                var options = new RewriteOptions()
                              .AddRedirectToHttps();
                app.UseRewriter(options);
            }

            // Initialize database
            DbInitializer.Initialize(context, logger, env.IsDevelopment());

            // Initialize storage
            Storage.Initialize(Configuration, logger, env.IsDevelopment());

            // Initialize event hub pool
            EventHubs.Initialize(Configuration, logger);

            // Setup swagger
            if (Configuration.GetValue <bool>("BatchServer:SwaggerEnabled"))
            {
                // Enable middleware to serve generated Swagger as a JSON endpoint.
                app.UseSwagger();

                // Enable middleware to serve swagger-ui (HTML, JS, CSS etc.), specifying the Swagger JSON endpoint.
                app.UseSwaggerUI(c =>
                {
                    c.SwaggerEndpoint("/swagger/v1/swagger.json", "GAB Science Lab Batch Server v1.0");
                });
            }
        }
 /// <summary>
 /// Constructor for the BatchController class
 /// </summary>
 /// <param name="configuration"></param>
 /// <param name="context"></param>
 /// <param name="logger"></param>
 public BatchController(IConfiguration configuration, BatchServerContext context, ILoggerFactory logger)
 {
     _configuration = configuration;
     _context       = context;
     _logger        = logger.CreateLogger("GAB.BatchServer.API.Controllers");
 }