* fix linting issues

This commit is contained in:
Daniel Thomas 2021-11-23 16:47:05 +01:00
parent 4dc8b8fcd5
commit 5a5a170f2e
2 changed files with 5 additions and 4 deletions

View File

@ -86,7 +86,7 @@ func NewCache(l *zap.Logger, webHooks func() []string) *Cache {
} }
func getCacheIDForRequest(r *http.Request, pathPrefix func() string) cacheID { func getCacheIDForRequest(r *http.Request, pathPrefix func() string) cacheID {
id := stripPrefixFromUrl(r.URL.RequestURI(), pathPrefix) id := stripPrefixFromURL(r.URL.RequestURI(), pathPrefix)
keys := make([]string, len(r.Header)) keys := make([]string, len(r.Header))
i := 0 i := 0
for k := range r.Header { for k := range r.Header {
@ -108,6 +108,6 @@ func getCacheIDForRequest(r *http.Request, pathPrefix func() string) cacheID {
return cacheID(id) return cacheID(id)
} }
func stripPrefixFromUrl(url string, pathPrefix func() string) string { func stripPrefixFromURL(url string, pathPrefix func() string) string {
return strings.Replace(url, pathPrefix(), "", 1) return strings.Replace(url, pathPrefix(), "", 1)
} }

View File

@ -1,9 +1,10 @@
package proxy package proxy
import ( import (
"net/http"
"github.com/foomo/contentfulproxy/packages/go/log" "github.com/foomo/contentfulproxy/packages/go/log"
"go.uber.org/zap" "go.uber.org/zap"
"net/http"
) )
type requestJobDone struct { type requestJobDone struct {
@ -22,7 +23,7 @@ type jobRunner func(job requestJob, id cacheID)
func getJobRunner(l *zap.Logger, c *Cache, backendURL func() string, pathPrefix func() string, chanJobDone chan requestJobDone) jobRunner { func getJobRunner(l *zap.Logger, c *Cache, backendURL func() string, pathPrefix func() string, chanJobDone chan requestJobDone) jobRunner {
return func(job requestJob, id cacheID) { return func(job requestJob, id cacheID) {
// backend url is the contentful api domain like https://cdn.contenful.com // backend url is the contentful api domain like https://cdn.contenful.com
calledURL := backendURL() + stripPrefixFromUrl(job.request.URL.RequestURI(), pathPrefix) calledURL := backendURL() + stripPrefixFromURL(job.request.URL.RequestURI(), pathPrefix)
l.Info("URL called by job-runner", log.FURL(calledURL)) l.Info("URL called by job-runner", log.FURL(calledURL))
req, err := http.NewRequest("GET", calledURL, nil) req, err := http.NewRequest("GET", calledURL, nil)
if err != nil { if err != nil {