feat(sdkserver): support catalog proxying in apiGachabaseFetch
This commit is contained in:
1 parent
a6f5ca6779
commit
5159d7ef14
1 file changed
+11
-1
@@ -523,7 +523,8 @@ func apiGachabaseFetch(w http.ResponseWriter, r *http.Request) {
|
|||||||
lang = "en"
|
lang = "en"
|
||||||
}
|
}
|
||||||
|
|
||||||
if targetURL == "" && targetID != "" && targetType != "" {
|
if targetURL == "" && targetType != "" {
|
||||||
|
if targetID != "" {
|
||||||
switch targetType {
|
switch targetType {
|
||||||
case "character", "avatar":
|
case "character", "avatar":
|
||||||
targetURL = fmt.Sprintf("https://hsr.gachabase.net/characters/%s/slug/%s?lang=%s", targetID, branch, lang)
|
targetURL = fmt.Sprintf("https://hsr.gachabase.net/characters/%s/slug/%s?lang=%s", targetID, branch, lang)
|
||||||
@@ -532,7 +533,16 @@ func apiGachabaseFetch(w http.ResponseWriter, r *http.Request) {
|
|||||||
case "relic":
|
case "relic":
|
||||||
targetURL = fmt.Sprintf("https://hsr.gachabase.net/relics/%s/slug/%s?lang=%s", targetID, branch, lang)
|
targetURL = fmt.Sprintf("https://hsr.gachabase.net/relics/%s/slug/%s?lang=%s", targetID, branch, lang)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
switch targetType {
|
||||||
|
case "characters", "avatars":
|
||||||
|
targetURL = fmt.Sprintf("https://hsr.gachabase.net/characters?branch=%s&lang=%s", branch, lang)
|
||||||
|
case "lightcones", "lcs":
|
||||||
|
targetURL = fmt.Sprintf("https://hsr.gachabase.net/lightcones?branch=%s&lang=%s", branch, lang)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if targetURL == "" {
|
if targetURL == "" {
|
||||||
writeJSON(w, map[string]any{"error": "missing url or id/type parameters", "status": 400})
|
writeJSON(w, map[string]any{"error": "missing url or id/type parameters", "status": 400})
|
||||||
|
|||||||
Reference in new issue
Block a user