fix: add context to HTTP request in getToken and simplify HTTP client initialization

This commit is contained in:
krau
2025-10-28 17:59:21 +08:00
parent 7a2a530e49
commit 44de871f63
2 changed files with 2 additions and 10 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ func (a *Alist) getToken(ctx context.Context) error {
return fmt.Errorf("failed to marshal login request: %w", err)
}
req, err := http.NewRequest(http.MethodPost, a.baseURL+"/api/auth/login", bytes.NewBuffer(loginBody))
req, err := http.NewRequestWithContext(ctx, http.MethodPost, a.baseURL+"/api/auth/login", bytes.NewBuffer(loginBody))
if err != nil {
return fmt.Errorf("failed to create login request: %w", err)
}