![]() |
Sphyrnidae Common Library
2.0.1
Shared Utilities/Library
|
The IRequestData interface provides a number of methods for accessing HttpRequest data. The implementation is registered as request-scoped, and pulls everything it needs from IHttpData. Because of this dependency, many of these methods are not thread-safe (eg. will cause exceptions if the main thread has returned and the context has been disposed). Note that all of these properties do directly access the HttpRequest object, which does not account for these values being passed along in headers (see Http Client).
Interface: IRequestData
Mock: RequestDataMock
Implementation: RequestData
Property | Description | Implementation |
---|---|---|
Id | Gets the unique ID for the request (Typically called a CorrelationId) | Guid.NewGuid() |
LoggingOrder | Order of things being logged | (char)33 - will be incremented every time logging occurs |
IpAddress | Ip Address of the end user/client | None - just a place to set/get this property |
RemoteIpAddress | IP Address of the machine making this request (may not be the original) | IpAddress |
DisplayUrl | The base URL of the request | HttpRequest.GetDisplayUrl() |
Route | Route of an API Request | Route template for a controller action |
ContentData() | The raw content data of the request | GetBodyAsync |
HttpVerb | The Http Verb for the request | HttpRequest.Method |
Headers | Collection of Http Headers | HttpRequest.Headers.ToNameValueCollection() |
QueryString | Collection of QueryString variables | HttpRequest.Query |
FormData | Collection of Form variables | HttpRequest.Form |
Browser | Name/Description of the client browser | HttpRequest.Headers["User-Agent"] |
T GetEndpointObject<T>() | Retrieves some object about the actual endpoint | HttpContext.Features.Get<IEndpointFeature>().Endpoint.Metadata - locate T within collection |
GetHeader() | Retrieves an HTTP Header from the request | GetHeader |
GetHeaders() | The collection of HTTP Headers with the given name | HttpRequest.Headers[name] ?? default |
Compare this to Http Data
IRequestData request; // Should be injected var httpVerb = request.HttpVerb;