-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.go
More file actions
34 lines (25 loc) · 803 Bytes
/
controller.go
File metadata and controls
34 lines (25 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package controller
import (
"os"
"github.com/pangpanglabs/echoswagger/v2"
"github.com/s21toolkit/s21client"
)
var methodRegistry []func(echoswagger.ApiGroup, *AdapterController) = make([]func(echoswagger.ApiGroup, *AdapterController), 0)
func registerMethod(callback func(echoswagger.ApiGroup, *AdapterController)) {
methodRegistry = append(methodRegistry, callback)
}
type AdapterController struct {
client *s21client.Client
}
func New() AdapterController {
client := s21client.New(s21client.DefaultAuth(os.Getenv("S21_USERNAME"), os.Getenv("S21_PASSWORD")))
return AdapterController{
client: client,
}
}
func (c *AdapterController) Init(g echoswagger.ApiGroup) {
g.SetDescription("s21adapter API")
for _, methodInitializer := range methodRegistry {
methodInitializer(g, c)
}
}