Documentation
¶
Index ¶
- Constants
- func SetupMigrator(prefix string, connection *pgx.Conn, migrations fs.FS) (mig *migrate.Migrator, err error)
- type ConnGet
- type Middleware
- func (m *Middleware) AddDB(name, uri string) (err error)
- func (*Middleware) Defaults() middleware.Config
- func (m *Middleware) GetConn(name string) *pgxpool.Conn
- func (m *Middleware) Gin(c *gin.Context)
- func (m *Middleware) Setup(mc middleware.Config)
- func (m *Middleware) Sites(sites []interface{}) (err error)
- func (m *Middleware) Teardown()
- type MigrationSite
Constants ¶
View Source
const ContextKey string = "db"
ContextKey is the key that is used in a gin.Context to get the Middleware
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware return a handler that sets the db into the context of every request. uri is an url in the form dbtype:connectargs
func NewMiddleware ¶
func NewMiddleware() *Middleware
NewMiddleware return an initialized Middleware Object.
func (*Middleware) AddDB ¶
func (m *Middleware) AddDB(name, uri string) (err error)
AddDB adds an db connection to the middleware.
func (*Middleware) Defaults ¶
func (*Middleware) Defaults() middleware.Config
Defaults returns an default config for connections
func (*Middleware) GetConn ¶
func (m *Middleware) GetConn(name string) *pgxpool.Conn
GetConn returns a connection from the specified database or if not found one of the default database.
func (*Middleware) Setup ¶
func (m *Middleware) Setup(mc middleware.Config)
Setup adds the connections from the configfile into the middleware
func (*Middleware) Sites ¶
func (m *Middleware) Sites(sites []interface{}) (err error)
Sites is an function for getting the migrations of the site
Click to show internal directories.
Click to hide internal directories.