Ejemplo n.º 1
0
        private async Task HandleSaveSnapshot(HttpContext context, ConfigServerOptions options)
        {
            if (context.Request.Method != "POST")
            {
                httpResponseFactory.BuildMethodNotAcceptedStatusResponse(context);
                return;
            }

            var command = await context.GetObjectFromJsonBodyAsync <CreateSnapshotCommand>();

            var commmandResult = await commandBus.SubmitAsync(command);

            await httpResponseFactory.BuildResponseFromCommandResult(context, commmandResult);
        }
Ejemplo n.º 2
0
        private async Task HandlePost(HttpContext context)
        {
            var data = await context.GetObjectFromJsonBodyAsync <ConfigurationClientPayload>();

            var commandResult = await commandBus.SubmitAsync(new CreateUpdateClientCommand(data));

            await httpResponseFactory.BuildResponseFromCommandResult(context, commandResult);
        }
Ejemplo n.º 3
0
        private async Task HandleUploadConfigurationSet(HttpContext context, string configSetName, ConfigurationClient client)
        {
            var configSet = configCollection.SingleOrDefault(c => configSetName.Equals(c.ConfigSetType.Name, StringComparison.OrdinalIgnoreCase));

            if (configSet == null)
            {
                httpResponseFactory.BuildNotFoundStatusResponse(context);
                return;
            }
            var json = await context.ReadBodyTextAsync();

            var result = await commandBus.SubmitAsync(new UpdateConfigurationSetFromJsonUploadCommand(BuildIdentity(client), configSet.ConfigSetType, json));

            await httpResponseFactory.BuildResponseFromCommandResult(context, result);

            return;
        }
Ejemplo n.º 4
0
        private async Task HandleGroupSaveRequest(HttpContext context)
        {
            var group = await context.GetObjectFromJsonBodyAsync <ConfigurationClientGroup>();

            var result = await commandBus.SubmitAsync(new CreateUpdateClientGroupCommand(group));

            await httpResponseFactory.BuildResponseFromCommandResult(context, result);
        }
        private async Task HandlePostRequest(HttpContext context, ConfigurationClient client, string configType)
        {
            var configModel = configCollection.SelectMany(s => s.Configs).SingleOrDefault(s => s.Type.Name.Equals(configType, StringComparison.OrdinalIgnoreCase));

            if (configModel == null)
            {
                httpResponseFactory.BuildNotFoundStatusResponse(context);
                return;
            }

            var command = new UpdateConfigurationFromEditorCommand(new ConfigurationIdentity(client, configCollection.GetVersion()), configModel.Type, await context.ReadBodyTextAsync());
            var result  = await commandBus.SubmitAsync(command);

            await httpResponseFactory.BuildResponseFromCommandResult(context, result);
        }