diff --git a/middleware/db/db.go b/middleware/db/db.go index 46d4c18..1ea44bc 100644 --- a/middleware/db/db.go +++ b/middleware/db/db.go @@ -29,7 +29,10 @@ var _ middleware.PostSetupMiddleware = &Middleware{} // GetConnection is an simple helper function that returns an connection to the db func GetConnection(c *gin.Context, db string) (*pgxpool.Conn, error) { if co, ok := c.Get(ContextKey); ok { - return co.(ConnGet)(db), nil + if cg, ok := co.(ConnGet); ok { + return cg(db), nil + } + return nil, fmt.Errorf("Failed to convert the method. %T != ConnGet", co) } return nil, errors.New("No db.Middleware set up. ") } @@ -101,7 +104,7 @@ func (m *Middleware) GetConn(name string) *pgxpool.Conn { // Gin is the Entrypoint for Gin. func (m *Middleware) Gin(c *gin.Context) { - c.Set(ContextKey, m.GetConn) + c.Set(ContextKey, ConnGet(m.GetConn)) } // Setup adds the connections from the configfile into the middleware