mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-20 06:25:07 +00:00
fix url proxy
This commit is contained in:
@@ -40,13 +40,11 @@ func Handler(w http.ResponseWriter, r *http.Request) {
|
|||||||
Path: r.URL.Path,
|
Path: r.URL.Path,
|
||||||
}
|
}
|
||||||
|
|
||||||
header := make(http.Header)
|
|
||||||
apiURL := APIHost + "/url/proxy"
|
apiURL := APIHost + "/url/proxy"
|
||||||
|
|
||||||
// use /v1/
|
// use /v1/
|
||||||
if len(APIKey) > 0 {
|
if len(APIKey) > 0 {
|
||||||
apiURL = APIHost + "/v1/url/proxy"
|
apiURL = APIHost + "/v1/url/proxy"
|
||||||
header.Set("Authorization", "Bearer "+APIKey)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// make new request
|
// make new request
|
||||||
@@ -55,6 +53,16 @@ func Handler(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if req.Header == nil {
|
||||||
|
req.Header = make(http.Header)
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the api key after we're given the header
|
||||||
|
if len(APIKey) > 0 {
|
||||||
|
req.Header.Set("Authorization", "Bearer "+APIKey)
|
||||||
|
}
|
||||||
|
|
||||||
// call the backend for the url
|
// call the backend for the url
|
||||||
rsp, err := http.DefaultClient.Do(req)
|
rsp, err := http.DefaultClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user