From be41c4bce167d79ab39816e42c4b0703a28dbdf3 Mon Sep 17 00:00:00 2001 From: Veronika Solovei Date: Fri, 3 May 2019 13:16:49 -0400 Subject: [PATCH] Minor refactoring --- stored_requests/backends/http_fetcher/fetcher.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/stored_requests/backends/http_fetcher/fetcher.go b/stored_requests/backends/http_fetcher/fetcher.go index 9777a21ba55..e33f883d3fc 100644 --- a/stored_requests/backends/http_fetcher/fetcher.go +++ b/stored_requests/backends/http_fetcher/fetcher.go @@ -86,17 +86,20 @@ func (fetcher *HttpFetcher) FetchCategories(ctx context.Context, primaryAdServer fetcher.Categories = make(map[string]map[string]stored_requests.Category) } - if publisherId == "" { - publisherId = primaryAdServer + //in NewFetcher function there is a code to add "?" at the end of url + //in case of categories we don't expect to have any parameters, that's why we need to remove "?" + url := fmt.Sprintf("%s/%s.json", strings.Replace(fetcher.Endpoint, "?", "", -1), primaryAdServer) + + dataName := primaryAdServer + + if publisherId != "" { + dataName = fmt.Sprintf("%s_%s", primaryAdServer, publisherId) + url = fmt.Sprintf("%s/%s/%s.json", strings.Replace(fetcher.Endpoint, "?", "", -1), primaryAdServer, publisherId) } - dataName := fmt.Sprintf("%s_%s", primaryAdServer, publisherId) if data, ok := fetcher.Categories[dataName]; ok { return data[iabCategory].Id, nil } - //in NewFetcher function there is a code to add "?" at the end of url - //in case of categories we don't expect to have any parameters, that's why we need to remove "?" - url := fmt.Sprintf("%s/%s/%s.json", strings.Replace(fetcher.Endpoint, "?", "", -1), primaryAdServer, publisherId) httpReq, err := http.NewRequest("GET", url, nil) if err != nil {