Add token management
This commit is contained in:
@@ -47,7 +47,7 @@ type RootResponse struct {
|
||||
}
|
||||
|
||||
func (zr *Handlers) generateResponse(resp http.ResponseWriter, req *http.Request) (*RootResponse, error) {
|
||||
userInfo, err := zr.api.GetUserInformation()
|
||||
userInfo, err := zr.rd.GetUserInformation()
|
||||
if err != nil {
|
||||
http.Error(resp, err.Error(), http.StatusInternalServerError)
|
||||
return nil, err
|
||||
@@ -77,7 +77,7 @@ func (zr *Handlers) generateResponse(resp http.ResponseWriter, req *http.Request
|
||||
sortedIDs := zr.torMgr.OnceDoneBin.ToSlice()
|
||||
sort.Strings(sortedIDs)
|
||||
|
||||
trafficDetails, err := zr.api.GetTrafficDetails()
|
||||
trafficDetails, err := zr.rd.GetTrafficDetails()
|
||||
if err != nil {
|
||||
http.Error(resp, err.Error(), http.StatusInternalServerError)
|
||||
return nil, err
|
||||
|
||||
@@ -24,7 +24,7 @@ type Handlers struct {
|
||||
downloader *universal.Downloader
|
||||
torMgr *torrent.TorrentManager
|
||||
cfg config.ConfigInterface
|
||||
api *realdebrid.RealDebrid
|
||||
rd *realdebrid.RealDebrid
|
||||
workerPool *ants.Pool
|
||||
hosts []string
|
||||
trafficOnStartup atomic.Uint64
|
||||
@@ -37,18 +37,18 @@ func init() {
|
||||
chi.RegisterMethod("MOVE")
|
||||
}
|
||||
|
||||
func AttachHandlers(router *chi.Mux, downloader *universal.Downloader, torMgr *torrent.TorrentManager, cfg config.ConfigInterface, api *realdebrid.RealDebrid, workerPool *ants.Pool, hosts []string, log *logutil.Logger) {
|
||||
func AttachHandlers(router *chi.Mux, downloader *universal.Downloader, torMgr *torrent.TorrentManager, cfg config.ConfigInterface, rd *realdebrid.RealDebrid, workerPool *ants.Pool, hosts []string, log *logutil.Logger) {
|
||||
hs := &Handlers{
|
||||
downloader: downloader,
|
||||
torMgr: torMgr,
|
||||
cfg: cfg,
|
||||
api: api,
|
||||
rd: rd,
|
||||
workerPool: workerPool,
|
||||
hosts: hosts,
|
||||
log: log,
|
||||
}
|
||||
|
||||
trafficDetails, err := api.GetTrafficDetails()
|
||||
trafficDetails, err := rd.GetTrafficDetails()
|
||||
if err != nil {
|
||||
log.Errorf("Failed to get traffic details: %v", err)
|
||||
trafficDetails = make(map[string]int64)
|
||||
|
||||
Reference in New Issue
Block a user