2022-08-25 19:26:29 -06:00
|
|
|
package middleware
|
|
|
|
|
|
|
|
import (
|
2023-08-27 18:09:46 -06:00
|
|
|
"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"
|
|
|
|
)
|
|
|
|
|
2024-02-09 10:10:06 -07:00
|
|
|
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) {
|
2023-01-10 20:23:47 -07:00
|
|
|
c.Set(pkg.ContextKeyTypeDatabase, deviceRepo)
|
2022-08-25 19:26:29 -06:00
|
|
|
c.Next()
|
|
|
|
}
|
|
|
|
}
|