public async Task <IActionResult> GetPostalCodeV2( [FromRoute] string objectId, [FromServices] IActionContextAccessor actionContextAccessor, [FromHeader(Name = HeaderNames.IfNoneMatch)] string ifNoneMatch, [FromServices] IsPostalCodeOsloApiEnabledToggle featureToggle, CancellationToken cancellationToken = default) { if (!featureToggle.FeatureEnabled) { return(NotFound()); } var contentFormat = DetermineFormat(actionContextAccessor.ActionContext); RestRequest BackendRequest() => CreateBackendDetailRequest(objectId); var cacheKey = $"oslo/postalinfo:{objectId}"; var value = await(CacheToggle.FeatureEnabled ? GetFromCacheThenFromBackendAsync( contentFormat.ContentType, BackendRequest, cacheKey, CreateDefaultHandleBadRequest(), cancellationToken) : GetFromBackendAsync( contentFormat.ContentType, BackendRequest, CreateDefaultHandleBadRequest(), cancellationToken)); return(new BackendResponseResult(value)); }
public async Task <IActionResult> ListPostalCodesV2( [FromQuery] int?offset, [FromQuery] int?limit, [FromQuery] string sort, [FromQuery] string gemeentenaam, [FromServices] IActionContextAccessor actionContextAccessor, [FromServices] IOptions <PostalOptionsV2> responseOptions, [FromHeader(Name = HeaderNames.IfNoneMatch)] string ifNoneMatch, [FromServices] IsPostalCodeOsloApiEnabledToggle 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, gemeentenaam); var cacheKey = CreateCacheKeyForRequestQuery($"oslo/postalinfo-list:{taal}"); var value = await(CacheToggle.FeatureEnabled ? GetFromCacheThenFromBackendAsync( contentFormat.ContentType, BackendRequest, cacheKey, CreateDefaultHandleBadRequest(), cancellationToken) : GetFromBackendAsync( contentFormat.ContentType, BackendRequest, CreateDefaultHandleBadRequest(), cancellationToken)); return(BackendListResponseResult.Create(value, Request.Query, responseOptions.Value.VolgendeUrl)); }
public async Task <IActionResult> CountPostalCodesV2( [FromQuery] string gemeentenaam, [FromServices] IActionContextAccessor actionContextAccessor, [FromHeader(Name = HeaderNames.IfNoneMatch)] string ifNoneMatch, [FromServices] IsPostalCodeOsloApiEnabledToggle featureToggle, CancellationToken cancellationToken = default) { if (!featureToggle.FeatureEnabled) { return(NotFound()); } var contentFormat = DetermineFormat(actionContextAccessor.ActionContext); IRestRequest BackendRequest() => CreateBackendCountRequest(gemeentenaam); return(new BackendResponseResult( await GetFromBackendAsync( contentFormat.ContentType, BackendRequest, CreateDefaultHandleBadRequest(), cancellationToken))); }