feat: updated server implementation

This commit is contained in:
David Allen 2025-08-18 11:09:51 -06:00
parent 0d27f07a8b
commit d56a9e452f
Signed by: towk
GPG key ID: 0430CDBE22619155
5 changed files with 348 additions and 75 deletions

View file

@ -9,7 +9,6 @@ import (
"os"
"path/filepath"
configurator "git.towk2.me/towk/configurator/pkg"
"github.com/go-chi/chi/v5"
"github.com/tidwall/sjson"
)
@ -26,7 +25,7 @@ type Profile struct {
func (s *Service) GetProfiles() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var (
path = s.RootPath + PROFILES_RELPATH
path = s.RootPath + RELPATH_PROFILES
profiles []*Profile
contents []byte
err error
@ -272,44 +271,6 @@ func (s *Service) GetProfileData() http.HandlerFunc {
// return func(w http.ResponseWriter, r *http.Request) {}
// }
func (s *Service) GetPlugins() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var (
plugins map[string]configurator.Plugin
names []string
body []byte
err error
)
plugins, err = LoadPluginsFromDir(s.PathForPlugins())
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
for name := range plugins {
names = append(names, name)
}
body, err = json.Marshal(names)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Write(body)
}
}
func (s *Service) CreatePlugins() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {}
}
func (s *Service) DeletePlugins() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {}
}
func loadProfileContents(path string) ([]byte, error) {
var (
contents []byte