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