@@ -29,8 +29,8 @@ import (
2929// 3) press F5 from browser. this'll inject 304 Not Modified into cache (browser expects 304 but CACHE NOT)
3030// 4) now use cURL to request the same resource (= without caching), and you'll get 304 🤦
3131
32- func New (appId string , opts erconfig.BackendOptsReverseProxy , logger * log.Logger ) (http.Handler , error ) {
33- handler , err := NewWithModifyResponse (appId , opts , nil )
32+ func New (appID string , opts erconfig.BackendOptsReverseProxy , logger * log.Logger ) (http.Handler , error ) {
33+ handler , err := NewWithModifyResponse (appID , opts , nil )
3434 if err != nil {
3535 return nil , err
3636 }
@@ -39,7 +39,7 @@ func New(appId string, opts erconfig.BackendOptsReverseProxy, logger *log.Logger
3939}
4040
4141func NewWithModifyResponse (
42- appId string ,
42+ appID string ,
4343 opts erconfig.BackendOptsReverseProxy ,
4444 modifyResponse func (r * http.Response ) error ,
4545) (http.Handler , error ) {
@@ -49,13 +49,13 @@ func NewWithModifyResponse(
4949 }
5050
5151 // transport that has optional TLS customizations and maybe caching (depending on options)
52- transport , err := maybeWrapWithCache (appId , opts , func () http.RoundTripper {
53- if opts .TlsConfig != nil { // got custom TLS config?
52+ transport , err := maybeWrapWithCache (appID , opts , func () http.RoundTripper {
53+ if opts .TLSConfig != nil { // got custom TLS config?
5454 return & http.Transport {
5555 TLSClientConfig : & tls.Config {
56- ServerName : opts .TlsConfig .ServerName ,
56+ ServerName : opts .TLSConfig .ServerName ,
5757 //nolint:gosec // InsecureSkipVerify intentionally configurable
58- InsecureSkipVerify : opts .TlsConfig .InsecureSkipVerify ,
58+ InsecureSkipVerify : opts .TLSConfig .InsecureSkipVerify ,
5959 },
6060 }
6161 } else {
@@ -72,7 +72,7 @@ func NewWithModifyResponse(
7272 //nolint:gosec // Cryptographical randomness not required here
7373 randomOriginIdx := rand .Intn (len (originUrls ))
7474
75- originUrl := originUrls [randomOriginIdx ]
75+ originURL := originUrls [randomOriginIdx ]
7676
7777 maybeIndexSuffix := func () string { // "/foo/" => "/foo/index.html" (if configured)
7878 if opts .IndexDocument != "" && strings .HasSuffix (req .URL .Path , "/" ) {
@@ -82,19 +82,19 @@ func NewWithModifyResponse(
8282 }
8383 }()
8484
85- req .URL .Scheme = originUrl .Scheme // "http" | "https"
85+ req .URL .Scheme = originURL .Scheme // "http" | "https"
8686
8787 // this specifies the host we're connecting to
88- req .URL .Host = originUrl .Host
88+ req .URL .Host = originURL .Host
8989
9090 // sometimes we want the outgoing request to include the original "Host: ..." header, so
9191 // the backend can see what hostname is in browser's address bar
9292 if ! opts .PassHostHeader {
93- req .Host = originUrl .Host
93+ req .Host = originURL .Host
9494 }
9595
9696 // origin's Path is "normally" empty (e.g. "http://example.com"), but can be used to add a prefix
97- req .URL .Path = originUrl .Path + req .URL .Path + maybeIndexSuffix
97+ req .URL .Path = originURL .Path + req .URL .Path + maybeIndexSuffix
9898
9999 // remove query string if we know we're serving static content and the output does
100100 // not vary based on query string. someone malicious could even be trying to flood our
@@ -115,7 +115,7 @@ func NewWithModifyResponse(
115115}
116116
117117func maybeWrapWithCache (
118- appId string ,
118+ appID string ,
119119 opts erconfig.BackendOptsReverseProxy ,
120120 inner http.RoundTripper ,
121121) (http.RoundTripper , error ) {
@@ -124,7 +124,7 @@ func maybeWrapWithCache(
124124 }
125125
126126 // there's no abstraction for getting system-level cache dir in Go
127- cacheLocation := filepath .Join ("/var/cache/edgerouter" , appId )
127+ cacheLocation := filepath .Join ("/var/cache/edgerouter" , appID )
128128
129129 if err := os .MkdirAll (cacheLocation , 0700 ); err != nil {
130130 return nil , fmt .Errorf ("cachingreverseproxy: %w" , err )
@@ -142,21 +142,21 @@ func maybeWrapWithCache(
142142 return cache , nil
143143}
144144
145- func parseOriginUrls (originUrlStrs []string ) ([]url.URL , error ) {
146- originUrls := []url.URL {}
145+ func parseOriginUrls (originURLStrs []string ) ([]url.URL , error ) {
146+ originURLs := []url.URL {}
147147
148- for _ , originUrlStr := range originUrlStrs {
149- originUrl , err := url .Parse (originUrlStr )
148+ for _ , originURLStr := range originURLStrs {
149+ originURL , err := url .Parse (originURLStr )
150150 if err != nil {
151151 return nil , err
152152 }
153153
154- originUrls = append (originUrls , * originUrl )
154+ originURLs = append (originURLs , * originURL )
155155 }
156156
157- if len (originUrls ) == 0 {
157+ if len (originURLs ) == 0 {
158158 return nil , errors .New ("empty origin list" )
159159 }
160160
161- return originUrls , nil
161+ return originURLs , nil
162162}
0 commit comments