Skip to content

Commit

Permalink
KevinDockx#130 Swappable input implementations for eTag generation
Browse files Browse the repository at this point in the history
  • Loading branch information
todd committed Jan 6, 2024
1 parent fbc3bce commit 401a5d7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,25 @@ public interface IETagGenerator
string responseBodyContent);
}
````
## IETagInjector

You can inject an IETagInjector-implementing class to modify how, where and when ETags are provided. The default implementation (DefaultETagInjector) injects the DefaultETag generator using the response body on the http context as the string along with the provided request key.

````csharp
/// <summary>
/// Contract for a ETagInjector, which can be used to inject custom eTags for resources
/// of which may be injected in the request pipeline (eg: based on existing calculated eTag on resource and store key)
/// </summary>
/// <remarks>
/// This injector will wrap the <see cref="IETagGenerator" /> to allow for eTag source to be swapped out
/// based on the <see cref="HttpContext" /> (rather than extend the interface of <see cref="IETagInjector" /> to
/// to extended including the <see cref="HttpContext" />
/// </remarks>
public interface IETagInjector
{
Task<ETag> RetrieveETag(ETagContext eTagContext);
}
````

## ILastModifiedInjector

Expand Down
4 changes: 2 additions & 2 deletions src/Marvin.Cache.Headers/Interfaces/IETagInjector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
namespace Marvin.Cache.Headers.Interfaces;

/// <summary>
/// Contract for a LastModifiedInjector, which can be used to inject custom eTags for resources
/// of which may be injected in the request pipeline (eg: based on existing calculated eTag on resource and stored)
/// Contract for a ETagInjector, which can be used to inject custom eTags for resources
/// of which may be injected in the request pipeline (eg: based on existing calculated eTag on resource and store key)
/// </summary>
/// <remarks>
/// This injector will wrap the <see cref="IETagGenerator" /> to allow for eTag source to be swapped out
Expand Down

0 comments on commit 401a5d7

Please sign in to comment.