refactor: updated cmd and pkg implementations

This commit is contained in:
David Allen 2025-08-30 23:30:46 -06:00
parent d88ab2c01f
commit fbed466c3d
Signed by: towk
GPG key ID: 0430CDBE22619155
10 changed files with 287 additions and 196 deletions

View file

@ -181,18 +181,9 @@ func (s *Service) Download() http.HandlerFunc {
func (s *Service) Upload() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
}
}
func (s *Service) UploadPlugin() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
}
}
func (s *Service) UploadProfile() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var (
_ = s.PathForData() + strings.TrimPrefix(r.URL.Path, "/upload")
)
}
}
@ -239,6 +230,23 @@ func (s *Service) List() http.HandlerFunc {
}
}
func (s *Service) Delete() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var (
path = s.PathForData() + strings.TrimPrefix(r.URL.Path, "/delete")
err error
)
err = os.RemoveAll(path)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusOK)
}
}
func (s *Service) GetStatus(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(map[string]any{