refactor: updated cmd and pkg implementations
This commit is contained in:
parent
d88ab2c01f
commit
fbed466c3d
10 changed files with 287 additions and 196 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue