示例#1
0
    public PokeGateway(
        IMemoryCache memoryCache,
        IHttpClientFactory httpClientFactory,
        ILogger <PokeGateway> logger)
    {
        var options = new ClientOptions(new Uri("https://pokeapi.co/api/v2/"), httpClientFactory, logger)
        {
            LogRequests  = true,
            LogResponses = true,
            Retry        =
            {
                MaxRetries = 1
            }
        };

        options.AddPolicy(HttpPipelinePosition.PerCall, new ResponseMemoryCachePolicy(memoryCache));

        _httpPipeline = HttpPipelineBuilder.Build(options);
    }