forked from krakend/krakend-ce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
handler_factory.go
20 lines (18 loc) · 902 Bytes
/
handler_factory.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package krakend
import (
"github.com/devopsfaith/krakend-jose"
ginjose "github.com/devopsfaith/krakend-jose/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 = ginjose.HandlerFactory(handlerFactory, logger, rejecter)
handlerFactory = metricCollector.NewHTTPHandlerFactory(handlerFactory)
handlerFactory = opencensus.New(handlerFactory)
return handlerFactory
}