refactor: minor changes and fixes

This commit is contained in:
David Allen 2025-08-30 00:23:53 -06:00
parent b791b84890
commit dc8a9cff20
Signed by: towk
GPG key ID: 0430CDBE22619155
5 changed files with 11 additions and 25 deletions

View file

@ -2,7 +2,6 @@ package service
import (
"encoding/json"
"fmt"
"io"
"net/http"
"os"
@ -35,7 +34,6 @@ func (s *Service) ListPlugins() http.HandlerFunc {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
fmt.Printf("%v", plugins)
w.Write(body)
}

View file

@ -64,16 +64,6 @@ func (s *Service) ListProfiles() http.HandlerFunc {
}
}
// func (s *Service) CreateProfiles() http.HandlerFunc {
// return func(w http.ResponseWriter, r *http.Request) {
// var (
// path = chi.URLParam(r, "path")
// err error
// )
// }
// }
func (s *Service) GetProfile() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var (

View file

@ -184,15 +184,14 @@ func LoadPluginsFromDir(dirpath string) (map[string]makeshift.Plugin, error) {
// helper to check for valid extensions
var hasValidExt = func(path string) bool {
var validExts = []string{".so", ".dylib", ".dll"}
return slices.Contains(validExts, filepath.Ext(path))
return slices.Contains([]string{".so", ".dylib", ".dll"}, filepath.Ext(path))
}
// 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
// only try loading if file has .so extension
if info.IsDir() || err != nil || hasValidExt(path) {
if info.IsDir() || err != nil || !hasValidExt(path) {
return nil
}