forked from krakend/krakend-ce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandler_factory.go
30 lines (26 loc) · 1.3 KB
/
handler_factory.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
package krakend
import (
botdetector "github.com/devopsfaith/krakend-botdetector/gin"
"github.com/devopsfaith/krakend-jose"
ginjose "github.com/devopsfaith/krakend-jose/gin"
lua "github.com/devopsfaith/krakend-lua/router/gin"
metrics "github.com/devopsfaith/krakend-metrics/gin"
opencensus "github.com/devopsfaith/krakend-opencensus/router/gin"
juju "github.com/devopsfaith/krakend-ratelimit/juju/router/gin"
"github.com/devopsfaith/krakend/logging"
router "github.com/devopsfaith/krakend/router/gin"
)
// NewHandlerFactory returns a HandlerFactory with a rate-limit and a metrics collector middleware injected
func NewHandlerFactory(logger logging.Logger, metricCollector *metrics.Metrics, rejecter jose.RejecterFactory) router.HandlerFactory {
handlerFactory := juju.HandlerFactory
handlerFactory = lua.HandlerFactory(logger, handlerFactory)
handlerFactory = ginjose.HandlerFactory(handlerFactory, logger, rejecter)
handlerFactory = metricCollector.NewHTTPHandlerFactory(handlerFactory)
handlerFactory = opencensus.New(handlerFactory)
handlerFactory = botdetector.New(handlerFactory, logger)
return handlerFactory
}
type handlerFactory struct{}
func (h handlerFactory) NewHandlerFactory(l logging.Logger, m *metrics.Metrics, r jose.RejecterFactory) router.HandlerFactory {
return NewHandlerFactory(l, m, r)
}