35 lines
682 B
Go
35 lines
682 B
Go
package plugins
|
|
|
|
import (
|
|
"encoding/json"
|
|
"log"
|
|
"os"
|
|
"system-trace/core/types/constructor"
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
var plugins *[]constructor.Plugin
|
|
|
|
func LoadPlugins() {
|
|
dictpath := "plugins/dictionary/dict.json"
|
|
d, err := os.ReadFile(dictpath)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
if err := json.Unmarshal(d, &plugins); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
// MARK: GetPlugins godoc
|
|
// @Summary Get list of available plugins
|
|
// @Description Returns array of plugins
|
|
// @Produce json
|
|
// @Success 200 {object} []constructor.Plugin
|
|
// @Router /plugins [get]
|
|
func GetPlugins(c *fiber.Ctx) error {
|
|
return c.Status(fiber.StatusOK).JSON(plugins)
|
|
}
|