diff --git a/gateway/handlers/forwarding_proxy.go b/gateway/handlers/forwarding_proxy.go index ff2546a9..feac3fa2 100644 --- a/gateway/handlers/forwarding_proxy.go +++ b/gateway/handlers/forwarding_proxy.go @@ -14,7 +14,7 @@ import ( ) // MakeForwardingProxyHandler create a handler which forwards HTTP requests -func MakeForwardingProxyHandler(proxy *types.HttpClientReverseProxy, metrics *metrics.MetricOptions) http.HandlerFunc { +func MakeForwardingProxyHandler(proxy *types.HTTPClientReverseProxy, metrics *metrics.MetricOptions) http.HandlerFunc { baseURL := proxy.BaseURL.String() if strings.HasSuffix(baseURL, "/") { baseURL = baseURL[0 : len(baseURL)-1] diff --git a/gateway/server.go b/gateway/server.go index bd0fd3cf..1c9a15d9 100644 --- a/gateway/server.go +++ b/gateway/server.go @@ -40,7 +40,7 @@ func main() { servicePollInterval := time.Second * 5 - reverseProxy := types.NewHttpClientReverseProxy(config.FunctionsProviderURL, config.ReadTimeout) + reverseProxy := types.NewHTTPClientReverseProxy(config.FunctionsProviderURL, config.ReadTimeout) faasHandlers.Proxy = internalHandlers.MakeForwardingProxyHandler(reverseProxy, &metricsOptions) faasHandlers.RoutelessProxy = internalHandlers.MakeForwardingProxyHandler(reverseProxy, &metricsOptions) diff --git a/gateway/types/proxy_client.go b/gateway/types/proxy_client.go index faafdeae..495c164d 100644 --- a/gateway/types/proxy_client.go +++ b/gateway/types/proxy_client.go @@ -1,3 +1,6 @@ +// Copyright (c) OpenFaaS Project 2018. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + package types import ( @@ -7,8 +10,9 @@ import ( "time" ) -func NewHttpClientReverseProxy(baseURL *url.URL, timeout time.Duration) *HttpClientReverseProxy { - h := HttpClientReverseProxy{ +// NewHTTPClientReverseProxy proxies to an upstream host through the use of a http.Client +func NewHTTPClientReverseProxy(baseURL *url.URL, timeout time.Duration) *HTTPClientReverseProxy { + h := HTTPClientReverseProxy{ BaseURL: baseURL, } @@ -26,7 +30,8 @@ func NewHttpClientReverseProxy(baseURL *url.URL, timeout time.Duration) *HttpCli return &h } -type HttpClientReverseProxy struct { +// HTTPClientReverseProxy proxy to a remote BaseURL using a http.Client +type HTTPClientReverseProxy struct { BaseURL *url.URL Client *http.Client }