mirror of
https://github.com/openfaas/faas.git
synced 2025-06-09 08:46:48 +00:00
Apply comments and naming conventions to HTTP proxy
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
This commit is contained in:
parent
26e0de3497
commit
7120e4c5f4
@ -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]
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user