forked from krakend/krakend-ce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin.go
36 lines (31 loc) · 903 Bytes
/
plugin.go
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
35
36
package krakend
import (
"github.com/devopsfaith/krakend/logging"
client "github.com/devopsfaith/krakend/transport/http/client/plugin"
server "github.com/devopsfaith/krakend/transport/http/server/plugin"
)
// LoadPlugins loads and registers the plugins so they can be used if enabled at the configuration
func LoadPlugins(folder, pattern string, logger logging.Logger) {
n, err := client.Load(
folder,
pattern,
client.RegisterClient,
)
if err != nil {
logger.Warning("loading plugins:", err)
}
logger.Info("total http executor plugins loaded:", n)
n, err = server.Load(
folder,
pattern,
server.RegisterHandler,
)
if err != nil {
logger.Warning("loading plugins:", err)
}
logger.Info("total http handler plugins loaded:", n)
}
type pluginLoader struct{}
func (d pluginLoader) Load(folder, pattern string, logger logging.Logger) {
LoadPlugins(folder, pattern, logger)
}