add some routes
This commit is contained in:
31
routes/upstream/upstream.go
Normal file
31
routes/upstream/upstream.go
Normal file
@@ -0,0 +1,31 @@
|
||||
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")]
|
||||
}
|
||||
Reference in New Issue
Block a user