Skip to content

Services IHttpService

Mika Berglund edited this page Dec 25, 2025 · 1 revision

HTTP Service (IHttpService)

The HTTP Service is responsible for executing all outgoing HTTP requests made by Blazorade Id. It provides a single abstraction for sending HTTP requests to external endpoints, ensuring that all network communication flows through a consistent and replaceable service boundary.

This service does not build requests, manage authentication, or interpret responses. Its sole responsibility is to send a fully prepared HttpRequestMessage and return the resulting HttpResponseMessage.

Responsibilities

  • Execute HTTP requests on behalf of other services
  • Provide a single extensibility point for customizing HTTP request execution
  • Delegate HTTP transport concerns to the configured HttpClient infrastructure

Service Contract

The HTTP Service exposes the following members:

  • SendRequestAsync: Sends the specified HTTP request asynchronously and returns the HTTP response message

Default Implementation

The default implementation, HttpService, uses IHttpClientFactory to create HttpClient instances for sending requests. This aligns the service with modern .NET HTTP client lifecycle management and avoids common issues related to socket exhaustion and improper client reuse.

The default implementation performs no additional processing on the request or response. It forwards the request as-is and returns the response directly to the caller.

Extensibility

Applications may replace the default implementation by providing a custom implementation of the HTTP Service. This can be used to:

  • Add custom logging or diagnostics
  • Apply retry or resiliency policies
  • Integrate alternative HTTP client behavior
  • Instrument or monitor outbound HTTP traffic

Any custom implementation must honor the service contract and return the raw HttpResponseMessage resulting from the HTTP operation.

Usage Notes

  • The HTTP Service assumes that requests are fully constructed before being passed to the service
  • Authentication headers, request content, and target URIs must be set by the calling service
  • Response validation and error handling are the responsibility of the caller

References

Clone this wiki locally