Class MassiveServiceCollectionExtensions
- Namespace
- Microsoft.Extensions.DependencyInjection
- Assembly
- MassiveDotNet.Extensions.DependencyInjection.dll
Registers the Massive REST client in a service collection, wired through IHttpClientFactory.
public static class MassiveServiceCollectionExtensions
- Inheritance
-
MassiveServiceCollectionExtensions
- Inherited Members
Fields
HttpClientName
The name of the HttpClient registration the SDK issues requests on. Use it to reach the same pipeline from IHttpClientFactory directly.
public const string HttpClientName = "MassiveDotNet"
Field Value
Methods
AddMassive(IServiceCollection, Action<MassiveClientOptions>)
Registers the Massive REST client from a full set of options.
public static IHttpClientBuilder AddMassive(this IServiceCollection services, Action<MassiveClientOptions> configure)
Parameters
servicesIServiceCollectionThe service collection to add to.
configureAction<MassiveClientOptions>Configures the client options.
Returns
- IHttpClientBuilder
The builder for the underlying named HttpClient, so resilience, logging, or any other handler can be added to the same pipeline.
Remarks
There is deliberately no overload binding an IConfiguration
section. Timeout is a NodaTime Duration,
which the configuration binder cannot convert: a bound section compiles clean, raises no
warning, and silently leaves the default in place. Read the values yourself instead —
options.ApiKey = configuration["Massive:ApiKey"] — which is also free of reflection
and so stays Native AOT clean (D27).
Calling this more than once layers an additional options delegate but builds the HTTP pipeline only on the first call, so the API key is never attached twice.
Unlike core's transport, the registered pipeline logs. The Authorization header's
value is redacted unconditionally, so no consumer logging configuration can expose the key
(rule 11). The default Bearer scheme keeps the key out of the request URI as well, which is
the reason it is the default (D2).
Exceptions
- ArgumentNullException
servicesorconfigureis null.
AddMassive(IServiceCollection, string)
Registers the Massive REST client authenticated with an API key.
public static IHttpClientBuilder AddMassive(this IServiceCollection services, string apiKey)
Parameters
servicesIServiceCollectionThe service collection to add to.
apiKeystringThe Massive API key.
Returns
- IHttpClientBuilder
The builder for the underlying named HttpClient, so resilience, logging, or any other handler can be added to the same pipeline.
Exceptions
- ArgumentNullException
servicesis null.- ArgumentException
apiKeyis null or whitespace.