Beispiel #1
0
        public static Uri ToUri(this ApiProxyServerOptions options)
        {
            int portNumber = 80;

            int.TryParse(options.Port, out portNumber);
            UriBuilder uriBuilder = new UriBuilder(options.Scheme, options.Host, portNumber);

            return(uriBuilder.Uri);
        }
Beispiel #2
0
        public static IOptions <ProxyOptions> ToProxyOptions(this ApiProxyServerOptions options)
        {
            ProxyOptions proxyOptions = new ProxyOptions()
            {
                Host   = options.Host,
                Port   = options.Port,
                Scheme = options.Scheme
            };

            return(Options.Create(proxyOptions));
        }
Beispiel #3
0
        // ToDo:
        // - Replace MIDDLEWARE_NAME environment variable with variables the can be used with ApiServerOptions:
        // -- ApiProxyServer:Scheme
        // -- ApiProxyServer:Host
        // -- ApiProxyServer:Port
        // - Remove use of IConfiguration and MIDDLEWARE_NAME environment variable
        private void ConfigureApiProxyServerOptions(ApiProxyServerOptions options)
        {
            ApiProxyServerOptions defaultConfig = Configuration.GetSection("ApiProxyServer").Get <ApiProxyServerOptions>();

            if (defaultConfig != null)
            {
                options.Host   = defaultConfig.Host;
                options.Port   = defaultConfig.Port;
                options.Scheme = defaultConfig.Scheme;
            }

            string apiServerUri = Configuration["MIDDLEWARE_NAME"];

            if (apiServerUri != null)
            {
                string[] apiServerUriParts = apiServerUri.Split(':');
                string   host = apiServerUriParts[0];
                string   port = apiServerUriParts.Length > 1 ? apiServerUriParts[1] : "80";
                options.Scheme = "http";
                options.Host   = host;
                options.Port   = port;
            }
        }
Beispiel #4
0
        private void ConfigureApiProxyServerOptions(ApiProxyServerOptions options)
        {
            ApiProxyServerOptions defaultConfig = Configuration.GetSection("ApiProxyServer").Get <ApiProxyServerOptions>();

            ConfigureProxyServerOptions(options, defaultConfig);
        }