better error checking and small api change

This commit is contained in:
Zoe
2025-01-09 16:30:30 +00:00
parent d2e37617d4
commit ad0e949070
5 changed files with 53 additions and 27 deletions

View File

@@ -14,14 +14,14 @@ type GLoomI struct {
client *rpc.Client
}
func (p *GLoomI) Init() error {
func (p *GLoomI) Init() (*fiber.Config, error) {
// Connect to the RPC server
client, err := rpc.Dial("tcp", "localhost:7143")
if err != nil {
return fmt.Errorf("failed to connect to Gloom RPC server: %w", err)
return nil, fmt.Errorf("failed to connect to Gloom RPC server: %w", err)
}
p.client = client
return nil
return nil, nil
}
func (p *GLoomI) Name() string {
@@ -46,6 +46,7 @@ func (p *GLoomI) RegisterRoutes(router fiber.Router) {
apiRouter.Get("/plugins", func(c fiber.Ctx) error {
plugins, err := GetPlugins(p.client)
if err != nil {
fmt.Printf("plugs: %+v\n", plugins)
return c.Status(fiber.StatusInternalServerError).SendString("Failed to list plugins: " + err.Error())
}