public async Task Handle(HttpContext context, ConfigServerOptions options) { if (!CheckMethodAndAuthentication(context, options)) { return; } // clientId/ConfigSet.json // clientId/ConfigSet/Config.json var pathParams = context.ToPathParams(); if (pathParams.Length < 2) { httpResponseFactory.BuildNotFoundStatusResponse(context); return; } var client = await configClientService.GetClientOrDefault(pathParams[0]); if (!context.ChallengeClientConfigurator(options, client, httpResponseFactory)) { return; } var payload = await GetPayloadOrDefault(pathParams, client); if (payload == null) { httpResponseFactory.BuildNotFoundStatusResponse(context); } else { await httpResponseFactory.BuildJsonFileResponse(context, payload.Payload, payload.FileName); } }
private async Task HandleTwoParams(HttpContext context, string[] pathParams, ConfigurationIdentity clientIdentity, ConfigServerOptions options) { switch (context.Request.Method) { case "GET": { if (!context.ChallengeClientConfigurator(options, clientIdentity.Client, httpResponseFactory)) { return; } var result = await archive.GetArchiveConfig(pathParams[1], clientIdentity); if (!result.HasEntry) { httpResponseFactory.BuildNotFoundStatusResponse(context); } else { await httpResponseFactory.BuildJsonFileResponse(context, result.Content, result.Name); } break; } case "DELETE": { await archive.DeleteArchiveConfig(pathParams[1], clientIdentity); httpResponseFactory.BuildNoContentResponse(context); break; } default: { httpResponseFactory.BuildMethodNotAcceptedStatusResponse(context); break; } } }