You've already forked reloading-manager
26 lines
388 B
Go
26 lines
388 B
Go
package database
|
|
|
|
import (
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
type CustomContext struct {
|
|
echo.Context
|
|
Db *Database
|
|
}
|
|
|
|
func CreateDatabaseMiddleware() echo.MiddlewareFunc {
|
|
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
|
return func(c echo.Context) error {
|
|
cc := &CustomContext{
|
|
Context: c,
|
|
Db: GetNewDatabase(),
|
|
}
|
|
|
|
res := next(cc)
|
|
|
|
return res
|
|
}
|
|
}
|
|
}
|