diff --git a/proxy/cache.go b/proxy/cache.go index 0708f40..19aee7a 100644 --- a/proxy/cache.go +++ b/proxy/cache.go @@ -86,7 +86,7 @@ func NewCache(l *zap.Logger, webHooks func() []string) *Cache { } 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)) i := 0 for k := range r.Header { @@ -108,6 +108,6 @@ func getCacheIDForRequest(r *http.Request, pathPrefix func() string) cacheID { 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) } diff --git a/proxy/jobs.go b/proxy/jobs.go index a3e1c1c..9c17c81 100644 --- a/proxy/jobs.go +++ b/proxy/jobs.go @@ -1,9 +1,10 @@ package proxy import ( + "net/http" + "github.com/foomo/contentfulproxy/packages/go/log" "go.uber.org/zap" - "net/http" ) 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 { return func(job requestJob, id cacheID) { // 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)) req, err := http.NewRequest("GET", calledURL, nil) if err != nil {