private async Task GetClientResource(HttpContext context, string resourceName, ConfigurationIdentity clientIdentity, ConfigServerOptions options) { if (!context.ChallengeClientReadOrConfigurator(options, clientIdentity.Client, httpResponseFactory)) { return; } var result = await resourceStore.GetResource(resourceName, clientIdentity); if (!result.HasEntry) { httpResponseFactory.BuildNotFoundStatusResponse(context); } else { await httpResponseFactory.BuildFileResponse(context, result.Content, result.Name); } }
private async Task HandleTwoParams(HttpContext context, string[] pathParams, ConfigServerOptions options, ConfigurationIdentity clientIdentity) { switch (context.Request.Method) { case "GET": { if (!context.ChallengeClientConfigurator(options, clientIdentity.Client, httpResponseFactory)) { break; } var result = await resourceArchive.GetArchiveResource(pathParams[1], clientIdentity); if (!result.HasEntry) { httpResponseFactory.BuildNotFoundStatusResponse(context); } else { await httpResponseFactory.BuildFileResponse(context, result.Content, result.Name); } break; } case "DELETE": { await resourceArchive.DeleteArchiveResource(pathParams[1], clientIdentity); httpResponseFactory.BuildNoContentResponse(context); break; } default: { httpResponseFactory.BuildMethodNotAcceptedStatusResponse(context); break; } } }