refactor: updated routes and handlers

This commit is contained in:
David Allen 2025-08-29 23:52:43 -06:00
parent 947fbba854
commit 4d96010199
Signed by: towk
GPG key ID: 0430CDBE22619155
3 changed files with 33 additions and 18 deletions

View file

@ -97,7 +97,6 @@ func (s *Service) Serve() error {
} else {
// general
// router.Handle("/download/*", http.StripPrefix("/download/", http.FileServer(http.Dir(s.PathForData()))))
router.Get("/download/*", s.Download())
router.Post("/upload/", s.Upload())
router.Post("/upload/plugin", s.UploadPlugin())
@ -106,18 +105,18 @@ func (s *Service) Serve() error {
// profiles
router.Get("/profiles", s.ListProfiles())
// router.Post("/profiles", s.CreateProfiles())
router.Get("/profile/{id}", s.GetProfile())
router.Post("/profile/{id}", s.CreateProfile())
router.Get("/profile/{id}/data", s.GetProfileData())
router.Post("/profile/{id}/data", s.SetProfileData())
router.Delete("/profile/{id}/data", s.DeleteProfileData())
router.Get("/profiles/{id}", s.GetProfile())
router.Post("/profiles/{id}", s.CreateProfile())
router.Get("/profiles/{id}/data", s.GetProfileData())
router.Post("/profiles/{id}/data", s.SetProfileData())
router.Delete("/profiles/{id}/data", s.DeleteProfileData())
// plugins
router.Get("/plugins", s.ListPlugins())
router.Get("/plugin/{name}", s.GetPlugin())
router.Post("/plugin/{name}", s.CreatePlugin())
router.Delete("/plugin/{name}", s.DeletePlugin())
router.Get("/plugins/{name}/info", s.GetPluginInfo())
router.Get("/plugins/{name}/raw", s.GetPluginRaw())
router.Post("/plugins/{name}", s.CreatePlugin())
router.Delete("/plugins/{name}", s.DeletePlugin())
}
// always available public routes go here
@ -192,12 +191,8 @@ func LoadPluginsFromDir(dirpath string) (map[string]makeshift.Plugin, error) {
// walk all files in directory only loading *valid* plugins
err = filepath.Walk(dirpath, func(path string, info fs.FileInfo, err error) error {
// skip trying to load generator plugin if directory or error
if info.IsDir() || err != nil {
return nil
}
// only try loading if file has .so extension
if hasValidExt(path) {
if info.IsDir() || err != nil || hasValidExt(path) {
return nil
}