Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Example of adding a WebProxy using DI #1181

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,6 @@ class Program
}
```

<a name="proxy"></a>
## Web Proxy

```csharp
var apiKey = Environment.GetEnvironmentVariable("SENDGRID_API_KEY");
var proxy = new WebProxy("http://proxy:1337");
var client = new SendGridClient(proxy, apiKey);
```

## HttpClientFactory + Microsoft.Extensions.DependencyInjection

> [SendGrid.Extensions.DependencyInjection](https://www.nuget.org/packages/SendGrid.Extensions.DependencyInjection) is required
Expand Down Expand Up @@ -234,6 +225,30 @@ class Program
}
```

<a name="proxy"></a>
## Web Proxy

```csharp
var apiKey = Environment.GetEnvironmentVariable("SENDGRID_API_KEY");
var proxy = new WebProxy("http://proxy:1337");
var client = new SendGridClient(proxy, apiKey);
```

Or when using DependencyInjection

```csharp
services.AddSendGrid(options =>
{
options.ApiKey = Environment.GetEnvironmentVariable("SENDGRID_API_KEY");
})
.ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler()
{
Proxy = new WebProxy(new Uri("http://proxy:1337")),
UseProxy = true
});
```


# Usage

- [Twilio SendGrid Docs](https://docs.sendgrid.com/api-reference/)
Expand Down