Reformat config for bins

This commit is contained in:
Ben Sarmiento
2024-05-26 11:59:26 +02:00
parent 6f2eadb059
commit de5cf68841

View File

@@ -10,7 +10,6 @@ import (
"github.com/debridmediamanager/zurg/internal/config" "github.com/debridmediamanager/zurg/internal/config"
"github.com/debridmediamanager/zurg/internal/version" "github.com/debridmediamanager/zurg/internal/version"
"github.com/debridmediamanager/zurg/pkg/realdebrid" "github.com/debridmediamanager/zurg/pkg/realdebrid"
mapset "github.com/deckarep/golang-set/v2"
) )
type SponsorResponse struct { type SponsorResponse struct {
@@ -19,23 +18,23 @@ type SponsorResponse struct {
Paypal string `json:"paypal"` Paypal string `json:"paypal"`
} }
type RootResponse struct { type RootResponse struct {
Version string `json:"version"` Version string `json:"version"`
BuiltAt string `json:"built_at"` BuiltAt string `json:"built_at"`
GitCommit string `json:"git_commit"` GitCommit string `json:"git_commit"`
Html string `json:"html"` Html string `json:"html"`
Dav string `json:"dav"` Dav string `json:"dav"`
Infuse string `json:"infuse"` Infuse string `json:"infuse"`
Logs string `json:"logs"` Logs string `json:"logs"`
UserInfo *realdebrid.User `json:"user_info"` // Replace UserInfoType with the actual type UserInfo *realdebrid.User `json:"user_info"` // Replace UserInfoType with the actual type
MemAlloc uint64 `json:"mem_alloc"` // Memory allocation in MB MemAlloc uint64 `json:"mem_alloc"` // Memory allocation in MB
TotalAlloc uint64 `json:"total_alloc"` // Total memory allocated in MB TotalAlloc uint64 `json:"total_alloc"` // Total memory allocated in MB
Sys uint64 `json:"sys"` // System memory in MB Sys uint64 `json:"sys"` // System memory in MB
NumGC uint32 `json:"num_gc"` // Number of completed GC cycles NumGC uint32 `json:"num_gc"` // Number of completed GC cycles
PID int `json:"pid"` // Process ID PID int `json:"pid"` // Process ID
Sponsor SponsorResponse `json:"sponsor_zurg"` // Sponsorship links Sponsor SponsorResponse `json:"sponsor_zurg"` // Sponsorship links
Config config.ZurgConfig `json:"config"` Config config.ZurgConfig `json:"config"`
ImmediateBin mapset.Set[string] `json:"immediate_bin"` ImmediateBin []string `json:"immediate_bin"`
OnceDoneBin mapset.Set[string] `json:"once_done_bin"` OnceDoneBin []string `json:"once_done_bin"`
} }
func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) { func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
@@ -68,8 +67,8 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
Paypal: "https://paypal.me/yowmamasita", Paypal: "https://paypal.me/yowmamasita",
}, },
Config: zr.cfg.GetConfig(), Config: zr.cfg.GetConfig(),
ImmediateBin: zr.torMgr.ImmediateBin, ImmediateBin: zr.torMgr.ImmediateBin.ToSlice(),
OnceDoneBin: zr.torMgr.OnceDoneBin, OnceDoneBin: zr.torMgr.OnceDoneBin.ToSlice(),
} }
out := `<table border="1px"> out := `<table border="1px">
@@ -257,11 +256,11 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
</tr> </tr>
<tr> <tr>
<td>Immediate Bin</td> <td>Immediate Bin</td>
<td colspan="2">%s</td> <td colspan="2">%v</td>
</tr> </tr>
<tr> <tr>
<td>Once Done Bin</td> <td>Once Done Bin</td>
<td colspan="2">%s</td> <td colspan="2">%v</td>
</tr> </tr>
<tr> <tr>
<td>Utilities</td> <td>Utilities</td>
@@ -345,8 +344,8 @@ func (zr *Handlers) handleHome(resp http.ResponseWriter, req *http.Request) {
response.Config.ShouldServeFromRclone(), response.Config.ShouldServeFromRclone(),
response.Config.ShouldForceIPv6(), response.Config.ShouldForceIPv6(),
response.Config.GetOnLibraryUpdate(), response.Config.GetOnLibraryUpdate(),
response.ImmediateBin.String(), response.ImmediateBin,
response.OnceDoneBin.String(), response.OnceDoneBin,
) )
fmt.Fprint(resp, out) fmt.Fprint(resp, out)