Skip to content

Commit

Permalink
improves service collection setup (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
runeanielsen authored May 23, 2022
1 parent 122b944 commit b08ae8d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Typesense/Setup/TypesenseExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ public static class TypesenseExtension
/// <exception cref="ArgumentNullException"></exception>
public static IServiceCollection AddTypesenseClient(this IServiceCollection serviceCollection, Action<Config> config)
{
serviceCollection.AddScoped<ITypesenseClient, TypesenseClient>();
serviceCollection.AddHttpClient<ITypesenseClient, TypesenseClient>();

if (config == null)
throw new ArgumentNullException(nameof(config), $"Please provide options for TypesenseClient.");

serviceCollection.Configure(config);
return serviceCollection;
return serviceCollection
.AddScoped<ITypesenseClient, TypesenseClient>()
.AddHttpClient<ITypesenseClient, TypesenseClient>().Services
.Configure(config);
}
}

0 comments on commit b08ae8d

Please sign in to comment.