32 lines
628 B
Go
32 lines
628 B
Go
package upstream
|
|
|
|
import (
|
|
"io"
|
|
"net/http"
|
|
"os"
|
|
)
|
|
|
|
var BaseUrls = map[string]string{
|
|
"TW": "https://v1010-bd.mobimon.com.tw",
|
|
"JP": "https://api.garupa.jp",
|
|
"GL": "https://api.app-bang-dream-gbp.com",
|
|
"CN": "https://l3-prod-all-bd.bilibiligame.net",
|
|
}
|
|
|
|
func Fetch(url string, headers map[string]string) ([]byte, error) {
|
|
req, _ := http.NewRequest("GET", url, nil)
|
|
for k, v := range headers {
|
|
req.Header.Set(k, v)
|
|
}
|
|
resp, err := http.DefaultClient.Do(req)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer resp.Body.Close()
|
|
return io.ReadAll(resp.Body)
|
|
}
|
|
|
|
func BaseUrl() string {
|
|
return BaseUrls[os.Getenv("SERVER")]
|
|
}
|