![]() |
Sphyrnidae Common Library
2.0.1
Shared Utilities/Library
|
The IHttpClientSettings is meant to abstract out communication with an HTTP Request. This interface basically works by allowing other abstractions to retrieve data from the HTTP Request via this abstraction. If you'd like to change the location of information in a HTTP Request, you can do so by updating this class. Most of the properties on this interface are the name of an HTTP Header, and a Get property to retrieve information from that property. Other components will use this interface to set these values in outgoing HTTP Responses.
The IHttpClientSettings interface has the following properties. The table below shows all properties, and what the default implementation does to implement.
Property | Default Implementation | Where used |
---|---|---|
ContentType | MediaTypeNames.Application.Json | None - this has been moved to ServiceConfiguration which is defaulted to JSON responses. |
JwtHeader | "Authorization" | JwtMiddleware: Sets the refreshed JWT into this header Api Logging: When logging the API request headers, this header will always be obfuscated WebServiceBase: Sets the JWT into this header for the outgoing HTTP Request |
Jwt |
| IdentityHelper: Obtains this JWT to convert to Identity |
RequestIdHeader | "V-Correlation-Id" | WebServiceBase: Where the requestId goes in the header for the outgoing HTTP Request |
RequestId |
| Logging: This value is always logged WebServiceBase: Retrieves this to forward into outgoing HTTP Request |
SessionIdHeader | "X-Tracking-Id" | WebServiceBase: Where the sessionId goes in the header for the outgoing HTTP Request |
SessionId | Reads from SessionIdHeader | Logging: This value is always logged WebServiceBase: Retrieves this to forward into outgoing HTTP Request |
IpAddressHeader | "X-Forwarded-For" | WebServiceBase: Where the IP Address goes in the header for the outgoing HTTP Request |
IpAddress |
| WebServiceBase: Retrieves this to forward into outgoing HTTP Request |
LogOrderHeader | "X-Logging-Order" | Logging: This value is always logged. The logger will also be responsible for placing the LogOrder into this header for web service requests |
LogOrder | Reads from LogOrderHeader | Logging: The existing value will be the prefix to the new value set into the header of outgoing HTTP requests. This value is also always logged. |
BearerAndLocalhostComparison | StringComparison.CurrentCultureIgnoreCase | Jwt: To strip out "bearer" IpAddress: To check for "localhost" |
Interface: IHttpClientSettings
Mock: HttpClientSettingsMock
Implementation: HttpClientSettings
IHttpClient http; // Should be injected var ipAddress = http.IpAddress; HttpHeaders headers; // Should be retrieved from the new HttpRequest object headers.Add(http.RequestIdHeader, http.RequestId);