~netlandish/gobwebs

89f8c57f62546da3bcd3b33fb18d36c7cdd168d4 — Peter Sanchez 1 year, 9 months ago ee64c3e
Adding DB as DBI interface for Context
1 files changed, 3 insertions(+), 1 deletions(-)

M server/server.go
M server/server.go => server/server.go +3 -1
@@ 20,6 20,7 @@ import (
	"github.com/labstack/echo/v4/middleware"
	"hg.code.netlandish.com/~netlandish/gobwebs"
	"hg.code.netlandish.com/~netlandish/gobwebs/config"
	"hg.code.netlandish.com/~netlandish/gobwebs/database"
	"hg.code.netlandish.com/~netlandish/gobwebs/email"
	"hg.code.netlandish.com/~netlandish/gobwebs/internal/localizer"
	"hg.code.netlandish.com/~netlandish/gobwebs/storage"


@@ 66,6 67,7 @@ type Server struct {
type Context struct {
	echo.Context
	Server *Server
	DB     database.DBI
	User   gobwebs.User
}



@@ 289,7 291,7 @@ func (s *Server) WithDefaultMiddleware() *Server {
	// Set custom context
	s.e.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
		return func(c echo.Context) error {
			ctx := &Context{Context: c, Server: s}
			ctx := &Context{Context: c, Server: s, DB: database.NewDB(s.DB)}
			return next(ctx)
		}
	})