File tree Expand file tree Collapse file tree 1 file changed +24
-9
lines changed Expand file tree Collapse file tree 1 file changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -185,15 +185,6 @@ class Program
185185}
186186```
187187
188- <a name =" proxy " ></a >
189- ## Web Proxy
190-
191- ``` csharp
192- var apiKey = Environment .GetEnvironmentVariable (" SENDGRID_API_KEY" );
193- var proxy = new WebProxy (" http://proxy:1337" );
194- var client = new SendGridClient (proxy , apiKey );
195- ```
196-
197188## HttpClientFactory + Microsoft.Extensions.DependencyInjection
198189
199190> [ SendGrid.Extensions.DependencyInjection] ( https://www.nuget.org/packages/SendGrid.Extensions.DependencyInjection ) is required
@@ -234,6 +225,30 @@ class Program
234225}
235226```
236227
228+ <a name =" proxy " ></a >
229+ ## Web Proxy
230+
231+ ``` csharp
232+ var apiKey = Environment .GetEnvironmentVariable (" SENDGRID_API_KEY" );
233+ var proxy = new WebProxy (" http://proxy:1337" );
234+ var client = new SendGridClient (proxy , apiKey );
235+ ```
236+
237+ Or when using DependencyInjection
238+
239+ ``` csharp
240+ services .AddSendGrid (options =>
241+ {
242+ options .ApiKey = Environment .GetEnvironmentVariable (" SENDGRID_API_KEY" );
243+ })
244+ .ConfigurePrimaryHttpMessageHandler (_ => new HttpClientHandler ()
245+ {
246+ Proxy = new WebProxy (new Uri (" http://proxy:1337" )),
247+ UseProxy = true
248+ });
249+ ```
250+
251+
237252# Usage
238253
239254- [ Twilio SendGrid Docs] ( https://docs.sendgrid.com/api-reference/ )
You can’t perform that action at this time.
0 commit comments