Class ServiceCollectionExtensions
- Namespace
- TypedRest
- Assembly
- TypedRest.dll
Provides extension methods for IServiceCollection.
public static class ServiceCollectionExtensions
- Inheritance
-
ServiceCollectionExtensions
- Inherited Members
Methods
AddBasicAuth(IHttpClientBuilder, Action<NetworkCredential>)
Adds HTTP Basic authentication.
public static IHttpClientBuilder AddBasicAuth(this IHttpClientBuilder builder, Action<NetworkCredential> configureCredentials)
Parameters
builder
IHttpClientBuilderThe builder to apply the configuration to.
configureCredentials
Action<NetworkCredential>A delegate that is used to configure NetworkCredential.
Returns
AddBasicAuth(IHttpClientBuilder, ICredentials)
Adds HTTP Basic authentication.
public static IHttpClientBuilder AddBasicAuth(this IHttpClientBuilder builder, ICredentials credentials)
Parameters
builder
IHttpClientBuilderThe builder to apply the configuration to.
credentials
ICredentialsA credential provider. Will be queried using BaseAddress as the uri and "Basic" as the authType.
Returns
AddTypedRest(IServiceCollection, Uri)
Registers EntryEndpoint for dependency injection.
public static IHttpClientBuilder AddTypedRest(this IServiceCollection services, Uri uri)
Parameters
services
IServiceCollectionThe IServiceCollection.
uri
UriThe base URI of the REST API. Missing trailing slash will be appended automatically.
Returns
- IHttpClientBuilder
An IHttpClientBuilder that can be used to configure the underlying HttpClient.
AddTypedRest<TEndpoint>(IServiceCollection, Uri)
Registers a type derived from EntryEndpoint for dependency injection.
public static IHttpClientBuilder AddTypedRest<TEndpoint>(this IServiceCollection services, Uri uri) where TEndpoint : EntryEndpoint
Parameters
services
IServiceCollectionThe IServiceCollection.
uri
UriThe base URI of the REST API. Missing trailing slash will be appended automatically.
Returns
- IHttpClientBuilder
An IHttpClientBuilder that can be used to configure the underlying HttpClient.
Type Parameters
TEndpoint
The type of the EntryEndpoint. Must provide a constructor that accepts an HttpClient.
AddTypedRest<TInterface, TEndpoint>(IServiceCollection, Uri)
Registers a type derived from EntryEndpoint for dependency injection.
public static IHttpClientBuilder AddTypedRest<TInterface, TEndpoint>(this IServiceCollection services, Uri uri) where TInterface : class where TEndpoint : EntryEndpoint, TInterface
Parameters
services
IServiceCollectionThe IServiceCollection.
uri
UriThe base URI of the REST API. Missing trailing slash will be appended automatically.
Returns
- IHttpClientBuilder
An IHttpClientBuilder that can be used to configure the underlying HttpClient.
Type Parameters
TInterface
The interface to register.
TEndpoint
The type of the EntryEndpoint. Must provide a constructor that accepts an HttpClient.