Class RemoteServiceInvokerBase
- Namespace
- GroupeIsa.Neos.ClusterCommunication
- Assembly
- GroupeIsa.Neos.ClusterCommunication.dll
A base client for interacting with endpoints over HTTP protocol.
public abstract class RemoteServiceInvokerBase : IRemoteServiceInvoker
- Inheritance
-
RemoteServiceInvokerBase
- Implements
- Derived
- Inherited Members
Constructors
RemoteServiceInvokerBase(IHttpClientFactory, IHttpContextAccessor, IApplicationContext, INeosLogger)
Initializes a new instance of the RemoteServiceInvokerBase class.
protected RemoteServiceInvokerBase(IHttpClientFactory httpClientFactory, IHttpContextAccessor httpContextAccessor, IApplicationContext applicationContext, INeosLogger logger)
Parameters
httpClientFactory
IHttpClientFactoryThe http client factory.
httpContextAccessor
IHttpContextAccessorProvides access to the current HttpContext.
applicationContext
IApplicationContextThe application context.
logger
INeosLoggerThe logger.
Fields
ImageMediaType
Represents the Image media type.
protected const string ImageMediaType = "image/*"
Field Value
JsonMediaType
Represents the JSON media type.
protected const string JsonMediaType = "application/json"
Field Value
_jsonSettings
Represents the JSON serializer settings.
protected static readonly JsonSerializerSettings _jsonSettings
Field Value
- JsonSerializerSettings
Properties
ApplicationContext
Gets the application context.
protected IApplicationContext ApplicationContext { get; }
Property Value
BaseUrl
Gets request base URL.
protected string BaseUrl { get; init; }
Property Value
ClientLogicalName
Gets The logical name of the HTTP client to create.
protected string ClientLogicalName { get; init; }
Property Value
HttpContextAccessor
Gets the HTTP context accessor.
protected IHttpContextAccessor HttpContextAccessor { get; }
Property Value
Methods
GetByteArrayAsync(RemoteServiceOptions)
Send a GET request with the specified options
and return the response body as a byte array.
public abstract Task<byte[]> GetByteArrayAsync(RemoteServiceOptions options)
Parameters
options
RemoteServiceOptionsThe options to invoke the method on.
Returns
- Task<byte[]>
A Task<TResult> that will return when the operation has completed with byte array.
GetStringAsync(RemoteServiceOptions)
Send a GET request with the specified options
and return the response body as a string.
public abstract Task<string> GetStringAsync(RemoteServiceOptions options)
Parameters
options
RemoteServiceOptionsThe options to invoke the method on.
Returns
- Task<string>
A Task<TResult> that will return when the operation has completed with string.
InvokeAsync(RemoteServiceOptions)
Performs service invocation for the service identified by options.ServiceId.ServiceId
and invokes the resource
specified by options.Path.Path
with the
HTTP method.options.HttpMethod.HttpMethod
public abstract Task InvokeAsync(RemoteServiceOptions options)
Parameters
options
RemoteServiceOptionsThe options to invoke the method on.
Returns
- Task
A Task<TResult> that will return when the operation has completed.
InvokeAsync<TResponse>(RemoteServiceOptions)
Performs service invocation for the service identified by options.ServiceId.ServiceId
and invokes the resource
specified by options.Path.Path
with the
HTTP method.options.HttpMethod.HttpMethod
public abstract Task<TResponse?> InvokeAsync<TResponse>(RemoteServiceOptions options)
Parameters
options
RemoteServiceOptionsThe options to invoke the method on.
Returns
- Task<TResponse>
A Task<TResult> that will return when the operation has completed.
Type Parameters
TResponse
The type of the data that will be JSON deserialized from the response body.
SendAsync(RemoteServiceOptions, HttpClient?)
Performs service invocation for the service identified by options.ServiceId.ServiceId
and invokes the resource
specified by options.Path.Path
with the
HTTP method.options.HttpMethod.HttpMethod
public virtual Task<HttpResponseMessage> SendAsync(RemoteServiceOptions options, HttpClient? client = null)
Parameters
options
RemoteServiceOptionsThe options to invoke the method on.
client
HttpClientProvides a HTTP client for sending HTTP requests and receiving HTTP responses.
Returns
- Task<HttpResponseMessage>
A Task<TResult> that will return when the operation has completed.
SendAsync(HttpRequestMessage, HttpClient?, CancellationToken)
Sends an HTTP request as an asynchronous operation.
public virtual Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, HttpClient? client = null, CancellationToken cancellationToken = default)
Parameters
request
HttpRequestMessageThe HTTP request message to send.
client
HttpClientProvides a HTTP client for sending HTTP requests and receiving HTTP responses.
cancellationToken
CancellationTokenThe cancellation token to cancel operation.
Returns
- Task<HttpResponseMessage>
A Task<TResult> that will return when the operation has completed.