fasten-onprem/backend/pkg/web/middleware/database.go

16 lines
416 B
Go
Raw Permalink Normal View History

2022-08-25 19:26:29 -06:00
package middleware
import (
"github.com/fastenhealth/fasten-onprem/backend/pkg"
"github.com/fastenhealth/fasten-onprem/backend/pkg/database"
2022-08-25 19:26:29 -06:00
"github.com/gin-gonic/gin"
)
func RepositoryMiddleware(deviceRepo database.DatabaseRepository) gin.HandlerFunc {
2022-08-25 19:26:29 -06:00
//TODO: determine where we can call defer deviceRepo.Close()
return func(c *gin.Context) {
c.Set(pkg.ContextKeyTypeDatabase, deviceRepo)
2022-08-25 19:26:29 -06:00
c.Next()
}
}