mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-14 12:04:41 +00:00
fix uri host
This commit is contained in:
@@ -16,6 +16,9 @@ var (
|
|||||||
|
|
||||||
// API Url
|
// API Url
|
||||||
APIHost = "https://api.m3o.com"
|
APIHost = "https://api.m3o.com"
|
||||||
|
|
||||||
|
// host to proxy for
|
||||||
|
Host = "m3o.one"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Handler(w http.ResponseWriter, r *http.Request) {
|
func Handler(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -40,6 +43,22 @@ func Handler(w http.ResponseWriter, r *http.Request) {
|
|||||||
Path: r.URL.Path,
|
Path: r.URL.Path,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if the host is blank we have to set it
|
||||||
|
if len(uri.Host) == 0 {
|
||||||
|
if len(r.Host) > 0 {
|
||||||
|
log.Printf("[url/proxy] Host is set from r.Host %v", r.Host)
|
||||||
|
uri.Host = r.Host
|
||||||
|
} else {
|
||||||
|
log.Printf("[url/proxy] Host is nil, defaulting to: %v", Host)
|
||||||
|
uri.Host = Host
|
||||||
|
uri.Scheme = "https"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(uri.Scheme) == 0 {
|
||||||
|
uri.Scheme = "https"
|
||||||
|
}
|
||||||
|
|
||||||
apiURL := APIHost + "/url/proxy"
|
apiURL := APIHost + "/url/proxy"
|
||||||
|
|
||||||
// use /v1/
|
// use /v1/
|
||||||
|
|||||||
Reference in New Issue
Block a user