Пример #1
0
        public async Task <ActionResult> GetBundleUri()
        {
            var input = await Request.GetRawBodyBytesAsync();

            var request  = Serializer.DeserializeAs <GetBundleUriRequest>(input);
            var response = new GetBundleUriResponse();

            try
            {
                var serverInfoIdList = await ConfigRepo.GetServerId(request.ServerIdentity);

                if (serverInfoIdList == null || serverInfoIdList.Count == 0)
                {
                    throw new Exception($"No server found with specified identity: {request.ServerIdentity}");
                }
                var bundleInfo = _serverInfoProvider.GetAllBundles().SingleOrDefault(b => b.ServerId == serverInfoIdList.First());
                if (bundleInfo == null)
                {
                    response.SetError("No bundles found");
                }
                else
                {
                    response.BundleUri = bundleInfo.Uri;
                }
            }
            catch (Exception ex)
            {
                response.SetError(ex.Message);
                LogError($"Error receiving bundles for {request.ServerIdentity}: {ex}");
            }

            return(new FileContentResult(Serializer.Serialize(response), "text/html"));
        }
Пример #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IShamanLogger logger, IRouterServerInfoProvider serverInfoProvider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();
            app.UseCookiePolicy();
            if (IsMetricsEnabled())
            {
                app.UseMiddleware <RequestMetricsMiddleWare>();
            }
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            serverInfoProvider.Start();

            logger.Error($"Initial server list: {JsonConvert.SerializeObject(serverInfoProvider.GetAllServers(), Formatting.Indented)}");
            logger.Error($"Initial bundles list: {JsonConvert.SerializeObject(serverInfoProvider.GetAllBundles(), Formatting.Indented)}");
        }