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

@ -8,6 +8,7 @@ import (
makeshift "git.towk2.me/towk/makeshift/pkg"
"github.com/go-chi/chi/v5"
"github.com/rs/zerolog/log"
)
func (s *Service) ListPlugins() http.HandlerFunc {
@ -124,24 +125,17 @@ func (s *Service) CreatePlugin() http.HandlerFunc {
func (s *Service) DeletePlugin() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var (
path string
plugin makeshift.Plugin
err error
pluginName = chi.URLParam(r, "name")
path = s.PathForPluginWithName(pluginName)
err error
)
plugin, err = getPluginFromRequestBody(r)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
path = s.PathForPluginWithName(plugin.Name())
log.Debug().Str("path", path).Send()
err = os.Remove(path)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusOK)
}
}