allow attaching middleware to server

This commit is contained in:
tsmethurst 2021-03-21 00:49:04 +01:00
parent 80873ed65e
commit f5b62e62d6
1 changed files with 5 additions and 1 deletions

View File

@ -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----"))