mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 16:12:24 -05:00 
			
		
		
		
	allow attaching middleware to server
This commit is contained in:
		
					parent
					
						
							
								80873ed65e
							
						
					
				
			
			
				commit
				
					
						f5b62e62d6
					
				
			
		
					 1 changed files with 5 additions and 1 deletions
				
			
		|  | @ -32,7 +32,7 @@ import ( | ||||||
| 
 | 
 | ||||||
| type Server interface { | type Server interface { | ||||||
| 	AttachHandler(method string, path string, handler gin.HandlerFunc) | 	AttachHandler(method string, path string, handler gin.HandlerFunc) | ||||||
| 	// AttachMiddleware(handler gin.HandlerFunc) | 	AttachMiddleware(handler gin.HandlerFunc) | ||||||
| 	GetAPIGroup() *gin.RouterGroup | 	GetAPIGroup() *gin.RouterGroup | ||||||
| 	Start() | 	Start() | ||||||
| 	Stop() | 	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 { | func New(config *config.Config, logger *logrus.Logger) Server { | ||||||
| 	engine := gin.New() | 	engine := gin.New() | ||||||
| 	store := memstore.NewStore([]byte("authentication-key"), []byte("encryption-keyencryption-key----")) | 	store := memstore.NewStore([]byte("authentication-key"), []byte("encryption-keyencryption-key----")) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue