From f5b62e62d683ee66c15239e5d83b07f147c22eaf Mon Sep 17 00:00:00 2001 From: tsmethurst Date: Sun, 21 Mar 2021 00:49:04 +0100 Subject: [PATCH] allow attaching middleware to server --- internal/api/server.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/api/server.go b/internal/api/server.go index 8e22742bb..5f98485b9 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -32,7 +32,7 @@ import ( type Server interface { AttachHandler(method string, path string, handler gin.HandlerFunc) - // AttachMiddleware(handler gin.HandlerFunc) + AttachMiddleware(handler gin.HandlerFunc) GetAPIGroup() *gin.RouterGroup Start() Stop() @@ -71,6 +71,10 @@ func (s *server) AttachHandler(method string, path string, handler gin.HandlerFu } } +func (s *server) AttachMiddleware(middleware gin.HandlerFunc) { + s.engine.Use(middleware) +} + func New(config *config.Config, logger *logrus.Logger) Server { engine := gin.New() store := memstore.NewStore([]byte("authentication-key"), []byte("encryption-keyencryption-key----"))