Skip to content
This repository has been archived by the owner on Jul 3, 2021. It is now read-only.

Fix OptionsPattern for ProxyOptions #74

Closed
datvm opened this issue Mar 4, 2019 · 1 comment
Closed

Fix OptionsPattern for ProxyOptions #74

datvm opened this issue Mar 4, 2019 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@datvm
Copy link
Contributor

datvm commented Mar 4, 2019

(I am pushing a pull request soon for this issue)

Currently Action<ProxyOptions> configureOptions is never called because of wrong DI declaration:

            services.Configure(configureOptions);
            services.AddTransient<ProxyOptions>();

Basically, ProxyOptions is always created and never configured if we put configureOptions in.

Suggestion: change the code to:

            services.AddOptions<ProxyOptions>()
                .Configure(configureOptions);

And currently, only WebSocketProxyMiddleware is using it, the correct DI declaration should be:

        public WebSocketProxyMiddleware(
            RequestDelegate next,
            IOptionsMonitor<ProxyOptions> options,
            Uri destinationUri,
            ILogger<WebSocketProxyMiddleware> logger)
        {
            _next = next;
            _options = options.CurrentValue;
            _destinationUri = destinationUri;
            _logger = logger;
        }
datvm added a commit to datvm/ProxyKit that referenced this issue Mar 4, 2019
damianh added a commit that referenced this issue Mar 5, 2019
Fix Options Pattern, issue #74.

Co-authored-by: Damian Hickey <dhickey@gmail.com>
@damianh
Copy link
Collaborator

damianh commented Mar 5, 2019

Thanks for PR!

@damianh damianh closed this as completed Mar 5, 2019
@damianh damianh added this to the v2.1.0 milestone Jun 17, 2019
@damianh damianh added the bug Something isn't working label Jun 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants