Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/newfuture/httpclientobserver
Diagnose your Http out-bound traffic with one line of code NewFuture.HttpClientObserver.SubscribeAll()
https://github.com/newfuture/httpclientobserver
dotnet httpclient
Last synced: about 1 month ago
JSON representation
Diagnose your Http out-bound traffic with one line of code NewFuture.HttpClientObserver.SubscribeAll()
- Host: GitHub
- URL: https://github.com/newfuture/httpclientobserver
- Owner: NewFuture
- License: mit
- Created: 2023-09-14T07:58:24.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-14T13:00:32.000Z (over 1 year ago)
- Last Synced: 2024-10-26T07:29:37.423Z (3 months ago)
- Topics: dotnet, httpclient
- Language: C#
- Homepage: https://www.nuget.org/packages/NewFuture.HttpClientObserver/
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HttpClientObserver
Diagnose your Http out-bound traffic with one line of code `NewFuture.HttpClientObserver.SubscribeAll()`.
It will log all `HttpClient` requests into the Diagnostic Tools Events view window.
**Highly recommend to use it in debug mode only with `#if DEBUG`** for performance and security reasons.
## Installation
install with nuget
```bash
dotnet add package NewFuture.HttpClientObserver
```## Usage
For example, you can add it to `Startup.cs` or `Program.cs` to subscribe all HttpClient events.
### Arguments
- `logResponseBody`: log response content, default is `true`;
- `ignoreUris`: ignore uri list in regex, default is the common urls in `HttpClientObserver.DefaultIgnoreUrlList`.### Examples
Basic usage
```csharp
// in Startup.cs#if DEBUG
// subscribe all HttpClient response in debug mode
NewFuture.HttpClientObserver.SubscribeAll();
#endif
```Ignore some urls
```csharp
// DefaultIgnoreUrlList contains some common urls, you can add your own
List ignoreList = new(HttpClientObserver.DefaultIgnoreUrlList)
{
new Regex("http://localhost.*")
};
// ignore uri list in regex
NewFuture.HttpClientObserver.SubscribeAll(ignoreUris: ignoreList);
```Don't log response body
```csharp
NewFuture.HttpClientObserver.SubscribeAll(false);
```## compatible
Only tested in Windows .NET 6.0, but it should work in other versions.