refactor: pass api_url through context (#457)

* refactor: pass `api_url` through context

* 移除 LinkArgs.HttpReq

* pref(alias): 减少不必要下载代理

* 修复bug

* net: 支持1并发 分片下载
This commit is contained in:
j2rong4cn
2025-06-30 15:48:05 +08:00
committed by GitHub
parent f0236522f3
commit 103abc942e
30 changed files with 209 additions and 222 deletions

View File

@ -1,6 +1,7 @@
package common
import (
"context"
"fmt"
"net/http"
stdpath "path"
@ -9,7 +10,7 @@ import (
"github.com/OpenListTeam/OpenList/internal/conf"
)
func GetApiUrl(r *http.Request) string {
func GetApiUrlFormRequest(r *http.Request) string {
api := conf.Conf.SiteURL
if strings.HasPrefix(api, "http") {
return strings.TrimSuffix(api, "/")
@ -28,3 +29,11 @@ func GetApiUrl(r *http.Request) string {
api = strings.TrimSuffix(api, "/")
return api
}
func GetApiUrl(ctx context.Context) string {
val := ctx.Value(conf.ApiUrlKey)
if api, ok := val.(string); ok {
return api
}
return ""
}