refactor: minor changes and fixes
This commit is contained in:
parent
b791b84890
commit
dc8a9cff20
5 changed files with 11 additions and 25 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue