Table of Contents

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

TBuilder
TResponse

Methods

AddAuthorization(IHttpAuthentication)

Add Authorization header based on the authentication method provided.

TBuilder AddAuthorization(IHttpAuthentication authentication)

Parameters

authentication IHttpAuthentication

Authentication 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

name string

Name of the header

value string

Value for the header

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

name string

Name of the query parameter to add

values IEnumerable<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

name string

Name of the query parameter to add

value string

Value of the parameter

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

parameters IEnumerable<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

dnsTimeout TimeSpan

Duration of the timeout

Returns

TBuilder

SetJsonRequestBody(object)

Sets the payload of the POST request in a JSON format.

TBuilder SetJsonRequestBody(object payload)

Parameters

payload object

Object 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

payload object

Object to serialize to a JSON format

serializerSettings JsonSerializerSettings

Serialization settings to use

Returns

TBuilder

SetJsonRequestBody(string)

Sets the payload of the POST request in a JSON format.

TBuilder SetJsonRequestBody(string jsonPayload)

Parameters

jsonPayload string

Already 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

jsonPayload string

Already serialized json

serializerSettings JsonSerializerSettings

Serialization settings to use

Returns

TBuilder

SetJsonResponseDeserializationSettings(JsonSerializerSettings)

Sets the deserialization settings used when parsing the response content.

TBuilder SetJsonResponseDeserializationSettings(JsonSerializerSettings serializerSettings)

Parameters

serializerSettings JsonSerializerSettings

Settings used for deserialization.

Returns

TBuilder

SetMetricsOptions(HttpRequestMetricsOptions)

Set options to control metrics sending behavior.

TBuilder SetMetricsOptions(HttpRequestMetricsOptions options)

Parameters

options HttpRequestMetricsOptions

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

amountOfRetries int

Amount 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

timeout TimeSpan

Duration 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

name string

Name of the HttpClient to use

Returns

TBuilder

UseLogger(ILogger)

Use specific logger for request logging.

TBuilder UseLogger(ILogger logger)

Parameters

logger ILogger

Returns

TBuilder