Fix upload logs

This commit is contained in:
2021-10-10 14:44:12 +10:30
parent 4534394abc
commit 6ece881a52
3 changed files with 24 additions and 14 deletions

View File

@@ -14,11 +14,13 @@ import (
"github.com/tardisx/discord-auto-upload/config"
daulog "github.com/tardisx/discord-auto-upload/log"
"github.com/tardisx/discord-auto-upload/upload"
"github.com/tardisx/discord-auto-upload/version"
)
type WebService struct {
Config *config.ConfigService
Config *config.ConfigService
Uploader *upload.Uploader
}
//go:embed data
@@ -149,19 +151,19 @@ func (ws *WebService) handleConfig(w http.ResponseWriter, r *http.Request) {
w.Write(b)
}
// func getUploads(w http.ResponseWriter, r *http.Request) {
// w.Header().Set("Content-Type", "application/json")
// ups := uploads.Uploads
// text, _ := json.Marshal(ups)
// w.Write([]byte(text))
// }
func (ws *WebService) getUploads(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
ups := ws.Uploader.Uploads
text, _ := json.Marshal(ups)
w.Write([]byte(text))
}
func (ws *WebService) StartWebServer() {
http.HandleFunc("/", ws.getStatic)
http.HandleFunc("/rest/logs", ws.getLogs)
// http.HandleFunc("/rest/uploads", getUploads)
http.HandleFunc("/rest/uploads", ws.getUploads)
http.HandleFunc("/rest/config", ws.handleConfig)
go func() {