add country
This commit is contained in:
@@ -4,23 +4,23 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/matst80/slask-finder/pkg/index"
|
||||
)
|
||||
|
||||
/** end */
|
||||
var baseUrl string
|
||||
|
||||
func init() {
|
||||
baseUrl = "https://slask-finder.tornberg.me"
|
||||
envUrl := os.Getenv("BASE_URL")
|
||||
if envUrl != "" {
|
||||
baseUrl = envUrl
|
||||
// TODO make this configurable
|
||||
func getBaseUrl(country string) string {
|
||||
// if country == "se" {
|
||||
// return "http://s10n-se:8080"
|
||||
// }
|
||||
if country == "no" {
|
||||
return "http://s10n-no:8080"
|
||||
}
|
||||
return "https://slask-finder.tornberg.me"
|
||||
}
|
||||
|
||||
func FetchItem(sku string) (*index.DataItem, error) {
|
||||
func FetchItem(sku string, country string) (*index.DataItem, error) {
|
||||
baseUrl := getBaseUrl(country)
|
||||
res, err := http.Get(fmt.Sprintf("%s/api/by-sku/%s", baseUrl, sku))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user