public async Task <IActionResult> GetBuildingV2( [FromRoute] int objectId, [FromServices] IActionContextAccessor actionContextAccessor, [FromHeader(Name = HeaderNames.IfNoneMatch)] string ifNoneMatch, [FromServices] IsBuildingOsloApiEnabledToggle featureToggle, CancellationToken cancellationToken = default) { if (!featureToggle.FeatureEnabled) { return(NotFound()); } var contentFormat = DetermineFormat(actionContextAccessor.ActionContext); RestRequest BackendRequest() => CreateBackendDetailRequest(objectId); // As long as we do not control WFS, buildings cannot be cached //var cacheKey = $"Oslo/building:{objectId}"; //var value = await (CacheToggle.FeatureEnabled // ? GetFromCacheThenFromBackendAsync(format, BackendRequest, cacheKey, Request.GetTypedHeaders(), CreateDefaultHandleBadRequest(), cancellationToken) // : GetFromBackendAsync(format, BackendRequest, Request.GetTypedHeaders(), CreateDefaultHandleBadRequest(), cancellationToken)); var value = await GetFromBackendAsync( contentFormat.ContentType, BackendRequest, CreateDefaultHandleBadRequest(), cancellationToken); return(new BackendResponseResult(value)); }
public async Task <IActionResult> ListBuildingsV2( [FromQuery] int?offset, [FromQuery] int?limit, [FromQuery] string sort, [FromQuery] string status, [FromServices] IActionContextAccessor actionContextAccessor, [FromServices] IOptions <BuildingOptionsV2> responseOptions, [FromHeader(Name = HeaderNames.IfNoneMatch)] string ifNoneMatch, [FromServices] IsBuildingOsloApiEnabledToggle featureToggle, CancellationToken cancellationToken = default) { if (!featureToggle.FeatureEnabled) { return(NotFound()); } var contentFormat = DetermineFormat(actionContextAccessor.ActionContext); const Taal taal = Taal.NL; IRestRequest BackendRequest() => CreateBackendListRequest( offset, limit, taal, sort, status); // As long as we do not control WFS, buildings cannot be cached //var cacheKey = CreateCacheKeyForRequestQuery($"legacy/building-list:{taal}"); //var value = await (CacheToggle.FeatureEnabled // ? GetFromCacheThenFromBackendAsync(format, BackendRequest, cacheKey, Request.GetTypedHeaders(), CreateDefaultHandleBadRequest(), cancellationToken) // : GetFromBackendAsync(format, BackendRequest, Request.GetTypedHeaders(), CreateDefaultHandleBadRequest(), cancellationToken)); var value = await GetFromBackendAsync( contentFormat.ContentType, BackendRequest, CreateDefaultHandleBadRequest(), cancellationToken); return(BackendListResponseResult.Create(value, Request.Query, responseOptions.Value.GebouwVolgendeUrl)); }
public async Task <IActionResult> CountBuildingsV2( [FromServices] IActionContextAccessor actionContextAccessor, [FromHeader(Name = HeaderNames.IfNoneMatch)] string ifNoneMatch, [FromServices] IsBuildingOsloApiEnabledToggle featureToggle, CancellationToken cancellationToken = default) { if (!featureToggle.FeatureEnabled) { return(NotFound()); } var contentFormat = BuildingOsloController.DetermineFormat(actionContextAccessor.ActionContext); IRestRequest BackendRequest() => CreateBackendCountRequest(); return(new BackendResponseResult( await GetFromBackendAsync( contentFormat.ContentType, BackendRequest, CreateDefaultHandleBadRequest(), cancellationToken))); }