public async Task Handle(HttpContext context, ConfigServerOptions options) { // Model/{ Client Id}/{ Configuration Set} // GET: Model for configuration set if (!CheckMethodAndAuthentication(context, options)) { return; } 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 configSet = configCollection.SingleOrDefault(c => pathParams[1].Equals(c.ConfigSetType.Name, StringComparison.OrdinalIgnoreCase)); if (configSet == null) { return; } await httpResponseFactory.BuildJsonResponse(context, await modelPayloadMapper.Map(configSet, new ConfigurationIdentity(client, configCollection.GetVersion()))); return; }
public async Task <bool> TryHandle(HttpContext context) { var routePath = context.Request.Path; if (string.IsNullOrWhiteSpace(routePath)) { await responseFactory.BuildResponse(context, GetConfigurationSetSummaries()); return(true); } PathString remainingPath; if (routePath.StartsWithSegments("/Model", out remainingPath)) { var queryResult = configCollection.TryMatchPath(c => c.ConfigSetType.Name, remainingPath); if (queryResult.HasResult) { await responseFactory.BuildResponse(context, modelPayloadMapper.Map(queryResult.QueryResult)); } return(queryResult.HasResult); } if (routePath.StartsWithSegments("/Value", out remainingPath)) { var configInstance = await configInstanceRouter.GetConfigInstanceOrDefault(remainingPath); if (configInstance == null || !(context.Request.Method == "GET" || context.Request.Method == "POST")) { return(false); } await HandleValueRequest(context, configInstance); return(true); } return(false); }