Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IHttpContextAccessor being singleton or not #12

Open
jiimaho opened this issue Dec 13, 2018 · 0 comments
Open

IHttpContextAccessor being singleton or not #12

jiimaho opened this issue Dec 13, 2018 · 0 comments

Comments

@jiimaho
Copy link

jiimaho commented Dec 13, 2018

Today IHttpContextAccessor is registered as singleton. I think it would be better to throw a runtime error if this is not the case, then the consumer would have to wire up this dependency manually instead. What do you think?

    public static IServiceCollection AddSwaggerGenWithBearerToken(this IServiceCollection services, Action<SwaggerGenOptions> setupAction)
    {
        services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
        services.AddSwaggerGen(options =>
        {
            setupAction.Invoke(options);
            options.EnableBearerTokenAuthorization();
        });
        return services;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant