Пример #1
0
        private async Task HandleSingleParam(HttpContext context, ConfigurationIdentity clientIdentity)
        {
            switch (context.Request.Method)
            {
            case "GET":
            {
                var clientResourceCatalogue = await archive.GetArchiveConfigCatalogue(clientIdentity);

                await httpResponseFactory.BuildJsonResponse(context, clientResourceCatalogue);

                break;
            }

            case "DELETE":
            {
                if (context.Request.Query.TryGetValue("before", out var pram) && DateTime.TryParse(pram, out var dateParam))
                {
                    await archive.DeleteOldArchiveConfigs(dateParam, clientIdentity);

                    httpResponseFactory.BuildNoContentResponse(context);
                    break;
                }
                httpResponseFactory.BuildNotFoundStatusResponse(context);
                break;
            }

            default:
            {
                httpResponseFactory.BuildMethodNotAcceptedStatusResponse(context);
                break;
            }
            }
        }
Пример #2
0
        private async Task SaveClientResource(HttpContext context, string resourceName, ConfigurationIdentity clientIdentity, ConfigServerOptions options)
        {
            if (!context.ChallengeClientConfigurator(options, clientIdentity.Client, httpResponseFactory))
            {
                return;
            }

            var file          = context.Request.Form.Files.Single();
            var uploadRequest = new UpdateResourceRequest
            {
                Name     = resourceName,
                Identity = clientIdentity,
                Content  = file.OpenReadStream()
            };
            await resourceStore.UpdateResource(uploadRequest);

            httpResponseFactory.BuildNoContentResponse(context);
        }