/// <summary> /// Adds the HCaptcha configuration <see cref="section"/> as <see cref="HCaptchaOptions"/>. /// Adds <see cref="IHCaptchaApi"/> as Refit Client with given base address in <see cref="HCaptchaOptions"/>. /// </summary> public static IServiceCollection AddHCaptcha(this IServiceCollection services, IConfigurationSection section) { HCaptchaOptions captchaOptions = new HCaptchaOptions(); section.Bind(captchaOptions); services.Configure <HCaptchaOptions>(section); services.AddRefitClient <IHCaptchaApi>() .ConfigureHttpClient(c => { c.BaseAddress = new Uri(captchaOptions.ApiBaseUrl); } ); services.AddScoped <IHCaptchaProvider, HCaptchaProvider>(); return(services); }
public HCaptchaModelBinder(IHCaptchaProvider captchaProvider, IOptions <HCaptchaOptions> captchaOptionsAccessor) { _captchaProvider = captchaProvider; _captchaOptions = captchaOptionsAccessor.Value; }
/// <summary> /// Creates an instance of <see cref="HCaptchaProvider"/> /// </summary> public HCaptchaProvider(IHCaptchaApi captchaApi, IOptions <HCaptchaOptions> captchaOptionsAccessor) { _captchaApi = captchaApi; _captchaOptions = captchaOptionsAccessor.Value; }