Interface IHttpRequestBuilder<TBuilder, TResponse>
- Namespace
- Homa.Sdk.Foundation
- Assembly
- Homa.Sdk.Foundation.dll
Interface for building all kinds of HTTP requests
public interface IHttpRequestBuilder<out TBuilder, TResponse>
Type Parameters
TBuilderTResponse
Methods
AddAuthorization(IHttpAuthentication)
Add Authorization header based on the authentication method provided.
TBuilder AddAuthorization(IHttpAuthentication authentication)
Parameters
authenticationIHttpAuthenticationAuthentication method to use.
Returns
- TBuilder
AddHeader(string, string)
Adds a header to the requests. Multiple values for each header can be provided that way.
TBuilder AddHeader(string name, string value)
Parameters
Returns
- TBuilder
AddQueryParameter(string, IEnumerable<string>)
Add query parameters. Multiple values of the same parameter are supported.
TBuilder AddQueryParameter(string name, IEnumerable<string> values)
Parameters
namestringName of the query parameter to add
valuesIEnumerable<string>Values of the collection represented by this parameter.
Returns
- TBuilder
AddQueryParameter(string, string)
Add query parameters. Multiple values of the same parameter are supported.
TBuilder AddQueryParameter(string name, string value)
Parameters
Returns
- TBuilder
Remarks
Adding a parameter with the same name multiple times will automatically convert it to a collection.
AddQueryParameters(IEnumerable<KeyValuePair<string, string>>)
Adds multiple query parameters. Multiple values of the same parameter are supported.
TBuilder AddQueryParameters(IEnumerable<KeyValuePair<string, string>> parameters)
Parameters
parametersIEnumerable<KeyValuePair<string, string>>Collection of key-value pairs representing the query parameters to add.
Returns
- TBuilder
An instance of the HTTP GET request builder.
Remarks
Adding a parameter with the same name multiple times will automatically convert it to a collection.
Build()
Build into a ready to send request.
IHttpRequest<TResponse> Build()
Returns
- IHttpRequest<TResponse>
SetDnsResolutionTimeout(TimeSpan)
Set the time after which DNS resolution should be aborted, and the request should fail. Default is 5 seconds.
TBuilder SetDnsResolutionTimeout(TimeSpan dnsTimeout)
Parameters
dnsTimeoutTimeSpanDuration of the timeout
Returns
- TBuilder
SetJsonRequestBody(object)
Sets the payload of the POST request in a JSON format.
TBuilder SetJsonRequestBody(object payload)
Parameters
payloadobjectObject to serialize to a JSON format
Returns
- TBuilder
SetJsonRequestBody(object, JsonSerializerSettings)
Sets the payload of the POST request in a JSON format.
TBuilder SetJsonRequestBody(object payload, JsonSerializerSettings serializerSettings)
Parameters
payloadobjectObject to serialize to a JSON format
serializerSettingsJsonSerializerSettingsSerialization settings to use
Returns
- TBuilder
SetJsonRequestBody(string)
Sets the payload of the POST request in a JSON format.
TBuilder SetJsonRequestBody(string jsonPayload)
Parameters
jsonPayloadstringAlready serialized json
Returns
- TBuilder
SetJsonRequestBody(string, JsonSerializerSettings)
Sets the payload of the POST request in a JSON format.
TBuilder SetJsonRequestBody(string jsonPayload, JsonSerializerSettings serializerSettings)
Parameters
jsonPayloadstringAlready serialized json
serializerSettingsJsonSerializerSettingsSerialization settings to use
Returns
- TBuilder
SetJsonResponseDeserializationSettings(JsonSerializerSettings)
Sets the deserialization settings used when parsing the response content.
TBuilder SetJsonResponseDeserializationSettings(JsonSerializerSettings serializerSettings)
Parameters
serializerSettingsJsonSerializerSettingsSettings used for deserialization.
Returns
- TBuilder
SetMetricsOptions(HttpRequestMetricsOptions)
Set options to control metrics sending behavior.
TBuilder SetMetricsOptions(HttpRequestMetricsOptions options)
Parameters
optionsHttpRequestMetricsOptions
Returns
- TBuilder
SetRetries(int)
Set the amount of retries that the query will attempt after a failed request due to timeout, network errors or 5xx server errors.
TBuilder SetRetries(int amountOfRetries)
Parameters
amountOfRetriesintAmount of retries if the first attempt fails.
Returns
- TBuilder
SetSingleRequestTimeout(TimeSpan)
Set the time after which a single attempt for sending a request should be canceled. Default is 100 seconds. It does not include the DNS resolver timeout.
TBuilder SetSingleRequestTimeout(TimeSpan timeout)
Parameters
timeoutTimeSpanDuration of the timeout
Returns
- TBuilder
- See Also
UseHttpClient(string)
Makes the builder to use client with specific name from the HttpClientFactory
TBuilder UseHttpClient(string name)
Parameters
namestringName of the HttpClient to use
Returns
- TBuilder
UseLogger(ILogger)
Use specific logger for request logging.
TBuilder UseLogger(ILogger logger)
Parameters
loggerILogger
Returns
- TBuilder