Пример #1
0
        /// <summary>
        /// Called by .NET Core runtime; configures the HTTP request pipeline.
        /// </summary>
        /// <param name="app"></param>
        /// <param name="env"></param>
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMvc();

            app.UseSwagger();

            app.UseSwaggerUI(c =>
            {
                c.RoutePrefix = "docs";
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Blox Bros Matchmaking API");
            });

            try
            {
                ApiAuthorize.SetGlobalApiKey(Configuration["GlobalApiKey"]);
                Player.MinMatchSize = int.Parse(Configuration["MinMatchSize"]);
                Player.MaxMatchSize = int.Parse(Configuration["MaxMatchSize"]);
                Player.MaxQueueTime = int.Parse(Configuration["MaxQueueTime"]);
            }
            catch (Exception e)
            {
                throw new Exception("appsettings.json file does not contain required key-value pair", e);
            }
        }
Пример #2
0
 /// <summary>
 /// 读取配置值  string redisPath = Configuration["RedisPath"];
 /// </summary>
 /// <param name="hostingEnvironment"></param>
 /// <param name="configuration"></param>
 public ApiBaseController(IOptions <ApiAuthorize> option)
 {
     apiAuthorize = option.Value;
 }