Interface IHttpConnectable
This interface provides extended methods, based on the IConnectable
interface to build http connections.
Inherited Members
Namespace: TeleScope.Connectors.Http.Abstractions
Assembly: TeleScope.Connectors.Http.Abstractions.dll
Syntax
public interface IHttpConnectable : IConnectable, IDisposable
Methods
| Improve this Doc View SourceAddCancelToken(CancellationToken)
The implementation shall add the
Declaration
IHttpConnectable AddCancelToken(CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | token | The token that is provided by the host system. |
Returns
Type | Description |
---|---|
IHttpConnectable | The calling instance. |
AddHeader(String, String)
Adds an http header to the next request as simple pair of name and value.
Declaration
IHttpConnectable AddHeader(string name, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the header information. |
System.String | value | The value of the header information. |
Returns
Type | Description |
---|---|
IHttpConnectable | The calling instance. |
CallAsync()
Performs the http request asynchronously that is defined by the http endpoint and optional parameters.
Declaration
Task<string> CallAsync()
Returns
Type | Description |
---|---|
Task<System.String> | The executing task whereby the result is the raw string of the response body. |
CallAsync<T>(Func<String, T>)
Performs the http request asynchronously that is defined by the http endpoint and optional parameters.
Declaration
Task<T> CallAsync<T>(Func<string, T> convert)
Parameters
Type | Name | Description |
---|---|---|
Func<System.String, T> | convert | The function converts the response body into the generic type T. |
Returns
Type | Description |
---|---|
Task<T> | The executing task whereby the result of the task is of type T. |
Type Parameters
Name | Description |
---|---|
T | The generic returned type T. |
Connect(HttpClient, HttpEndpoint)
Tests the connection with the given http client and endpoint and stores both parameters internally.
Declaration
IHttpConnectable Connect(HttpClient client, HttpEndpoint endpoint)
Parameters
Type | Name | Description |
---|---|---|
HttpClient | client | The http client that will be used by the connector. |
HttpEndpoint | endpoint | The endpoint configuration. |
Returns
Type | Description |
---|---|
IHttpConnectable | The calling instance. |
Connect(HttpEndpoint)
Tests the connection to the given endpoint and stores the parameter internally. The http client must be ready-to-use before calling this method.
Declaration
IHttpConnectable Connect(HttpEndpoint endpoint)
Parameters
Type | Name | Description |
---|---|---|
HttpEndpoint | endpoint | The endpoint configuration. |
Returns
Type | Description |
---|---|
IHttpConnectable | The calling instance. |
DisableCaching()
The implementation shall disable the caching mechanism and free all allocated memory.
Declaration
IHttpConnectable DisableCaching()
Returns
Type | Description |
---|---|
IHttpConnectable | The calling instance. |
SetContent(String)
Sets the payload of the http request which must be represented as json compliant string.
Declaration
IHttpConnectable SetContent(string jsonContent)
Parameters
Type | Name | Description |
---|---|---|
System.String | jsonContent | The payload for the next http request. |
Returns
Type | Description |
---|---|
IHttpConnectable | The calling instance. |
SetContent(String, Encoding, String)
Sets the payload of the next http request.
Declaration
IHttpConnectable SetContent(string content, Encoding encoding, string mediatype)
Parameters
Type | Name | Description |
---|---|---|
System.String | content | The payload as string. |
Encoding | encoding | The encoding to format the string before serialization. |
System.String | mediatype | The media type of the payload. |
Returns
Type | Description |
---|---|
IHttpConnectable | The calling instance. |
SetRequest(String, HttpMethod)
The implementation shall update the request part of the http endpoint configuration.
Declaration
IHttpConnectable SetRequest(string request, HttpMethod method)
Parameters
Type | Name | Description |
---|---|---|
System.String | request | The request part of the url. |
HttpMethod | method | The method type of the call. |
Returns
Type | Description |
---|---|
IHttpConnectable | The calling instance. |
SetRequest(HttpEndpoint)
The implementation shall update the complete http endpoint configuration.
Declaration
IHttpConnectable SetRequest(HttpEndpoint newEndpoint)
Parameters
Type | Name | Description |
---|---|---|
HttpEndpoint | newEndpoint | The new thhp endpoint. |
Returns
Type | Description |
---|---|
IHttpConnectable | The calling instance. |
WithCaching(UInt32, UInt32)
The implementation shall add a caching mechanism for all upcoming http requests.
Declaration
IHttpConnectable WithCaching(uint refreshSeconds = null, uint expirationSeconds = null)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | refreshSeconds | The timeout in seconds where the cache will return (refresh) the cached data. |
System.UInt32 | expirationSeconds | The timeout in seconds where the cache will expire the cached data. |
Returns
Type | Description |
---|---|
IHttpConnectable | The calling instance. |
WithCaching(TimeSpan, TimeSpan)
The implementation shall add a caching mechanism for all upcoming http requests.
Declaration
IHttpConnectable WithCaching(TimeSpan refreshExpiration, TimeSpan resetExpiration)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | refreshExpiration | The timeout where the cache will return (refresh) the cached data. |
TimeSpan | resetExpiration | The timeout where the cache will expire the cached data. |
Returns
Type | Description |
---|---|
IHttpConnectable | The calling instance. |