Skip to content

Commit 40cbcb2

Browse files
committed
Release v1.4.0: Support DI resolution of concrete HttpClientWithCache type
- Fix: HttpClientWithCache can now be resolved from DI container directly - Add documentation example for concrete type usage - Maintain backward compatibility with interface-based resolution - All 132 tests passing
1 parent 026c66d commit 40cbcb2

3 files changed

Lines changed: 51 additions & 41 deletions

File tree

docs/caching.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ using Reliable.HttpClient.Caching;
6767
// Register universal caching
6868
services.AddHttpClientWithCache();
6969

70-
// Use in your service
70+
// Use in your service - via interface
7171
public class ApiService(IHttpClientWithCache client)
7272
{
7373
public async Task<WeatherResponse> GetWeatherAsync(string city) =>
@@ -76,6 +76,13 @@ public class ApiService(IHttpClientWithCache client)
7676
public async Task<UserProfile> GetUserAsync(int id) =>
7777
await client.GetAsync<UserProfile>($"/users/{id}");
7878
}
79+
80+
// Alternative: Use concrete type (since v1.4.0)
81+
public class AlternativeApiService(HttpClientWithCache client)
82+
{
83+
public async Task<WeatherResponse> GetWeatherAsync(string city) =>
84+
await client.GetAsync<WeatherResponse>($"/weather?city={city}");
85+
}
7986
```
8087

8188
### 🚀 Preset-Based Configuration (Both Approaches)

src/Reliable.HttpClient.Caching/Generic/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ public class WeatherService(CachedHttpClient<WeatherResponse> client)
3838
3939
## Documentation
4040

41-
📖 **[Complete Caching Guide](../../docs/caching.md)** - Architecture, examples, and advanced usage
42-
🎯 **[Choosing the Right Approach](../../docs/choosing-approach.md)** - Decision guide
41+
📖 **[Complete Caching Guide](../../docs/caching.md)** - Architecture, examples, and advanced usage
42+
🎯 **[Choosing the Right Approach](../../docs/choosing-approach.md)** - Decision guide
4343
📝 **[Common Scenarios](../../docs/examples/common-scenarios.md)** - Real-world examples

src/Reliable.HttpClient.Caching/Reliable.HttpClient.Caching.csproj

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,51 @@
44
Directory.Build.props -->
55
<AssemblyName>Reliable.HttpClient.Caching</AssemblyName>
66
<PackageId>Reliable.HttpClient.Caching</PackageId>
7-
<Version>1.3.0</Version>
8-
<PackageReleaseNotes>🎉 v1.3.0 Release - PATCH Method Support &amp; Enhanced Caching!
7+
<Version>1.4.0</Version>
8+
<PackageReleaseNotes>🎉 v1.4.0 Release - Dependency Injection Enhancement; Backward
9+
Compatibility!
10+
11+
Major Bug Fix:
12+
13+
• Fixed HttpClientWithCache concrete type resolution from Dependency Injection container
14+
(Issue #5)
15+
• Both IHttpClientWithCache interface and HttpClientWithCache concrete type now resolvable
16+
from DI
17+
• Maintains complete backward compatibility with existing API signatures
18+
• Scoped service registration to avoid captive dependencies with internal HttpClient
19+
20+
API Enhancements:
21+
22+
• AddHttpClientWithCache now supports both HttpCacheOptions and
23+
Action&lt;HttpCacheOptions&gt;patterns
24+
• Dual registration: services.GetService&lt;HttpClientWithCache&gt;() and
25+
services.GetService&lt;IHttpClientWithCache&gt;() both work
26+
• Same singleton instance returned for both interface and concrete type requests
27+
• Comprehensive test coverage ensuring proper DI resolution behavior
28+
29+
Backward Compatible Overloads:
30+
31+
// Original API - preserved for backward compatibility
32+
services.AddHttpClientWithCache("client", cacheOptions);
33+
34+
// New API - Action&lt;T&gt; configuration pattern
35+
services.AddHttpClientWithCache("client", options =&gt; options.DefaultExpiry =
36+
TimeSpan.FromMinutes(5));
37+
38+
Key Benefits:
39+
40+
• Access to HttpClientWithCache-specific members not exposed through IHttpClientWithCache
41+
• Better integration with existing DI-based architectures
42+
• Follows .NET dependency injection best practices
43+
• Maintains performance and simplicity for basic scenarios
44+
45+
Previous Features (v1.3.0):
946

10-
✨ Major New Features:
1147
• Complete HTTP PATCH method support in HttpClientWithCache and CachedHttpClient&lt;T&gt;
12-
• Four PATCH method overloads matching main HttpClient module capabilities
13-
• Intelligent cache invalidation for PATCH operations - responses not cached, but related
14-
cache entries invalidated
15-
• Full header support for PATCH operations including OAuth and authentication scenarios
16-
• Smart error handling - cache remains intact if PATCH operation fails
17-
18-
🔧 API Enhancements:
19-
• PatchAsync&lt;TRequest, TResponse&gt;(uri, request) - Typed request/response with cache
20-
invalidation
21-
• PatchAsync&lt;TRequest, TResponse&gt;(uri, request, headers) - With custom headers support
22-
• PatchAsync&lt;TRequest&gt;(uri, request) - Returns raw HttpResponseMessage
23-
• PatchAsync&lt;TRequest&gt;(uri, request, headers) - Raw response with headers
24-
• Consistent caching behavior: GET operations cached, mutating operations (POST, PUT, PATCH)
25-
invalidate cache
26-
• Comprehensive test coverage (336+ tests) validating all PATCH scenarios
27-
28-
🎯 Key Use Cases:
29-
• RESTful API updates with intelligent cache management
30-
• Partial resource updates with cache invalidation patterns
31-
• Authentication-aware PATCH operations with header support
32-
• Multi-tenant PATCH operations with isolated cache invalidation
33-
• Error-resilient updates that preserve cache integrity on failures
34-
35-
🚀 Quick Start:
36-
// PATCH with automatic cache invalidation
37-
var updated = await client.PatchAsync&lt;UpdateRequest, UserResponse&gt;("/users/123",
38-
request);
39-
40-
// PATCH with headers and cache management
41-
await client.PatchAsync("/api/resource", data, headers);
42-
43-
🔄 Previous Features (v1.2.0):
48+
• Intelligent cache invalidation for PATCH operations
4449
• Full custom headers support matching main HttpClient module capabilities
45-
• DefaultHeaders property in HttpCacheOptions for static headers across all cached requests
46-
• Per-request headers support in all HTTP methods (GET, POST, PUT, DELETE)
50+
• Per-request headers support in all HTTP methods (GET, POST, PUT, DELETE, PATCH)
4751
• Intelligent cache key generation that includes headers for proper cache isolation
48-
• Enhanced HttpClientWithCache with comprehensive header support
4952

5053
📚 Full documentation: https://github.com/akrisanov/Reliable.HttpClient
5154

0 commit comments

Comments
 (0)