Documentation
¶
Index ¶
- Constants
- func Cleanup(c ConnData)
- func CreateDB(dbName string) (err error)
- func DropDB(dbName string) (err error)
- func GetAccountIDFromRequest(req *http.Request) (string, error)
- func GetDSN(params ConnParams) string
- func GetDefaultDSN() string
- func GetUserByToken(token string) (*models.User, error)
- type ConnData
- type ConnParams
- type Connection
Constants ¶
View Source
const TokenHeader string = "X-Lbry-Auth-Token"
TokenHeader is the name of HTTP header which is supplied by client and should contain internal-api auth_token
Variables ¶
This section is empty.
Functions ¶
func GetAccountIDFromRequest ¶
GetAccountIDFromRequest retrieves SDK account_id of a user making a http request by a header provided by the http client
func GetDSN ¶
func GetDSN(params ConnParams) string
GetDSN generates DSN string from config parameters, which can be overridden in params.
func GetDefaultDSN ¶
func GetDefaultDSN() string
GetDefaultDSN is a wrapper for GetDSN without params.
Types ¶
type ConnData ¶
type ConnData struct {
DB *sqlx.DB
Logger monitor.ModuleLogger
// contains filtered or unexported fields
}
ConnData holds connection data.
var Conn *ConnData
Conn is a module-level connection-holding variable
func NewConnection ¶
NewConnection sets up a database object, panics if unable to connect.
func (ConnData) MigrateDown ¶
func (c ConnData) MigrateDown()
MigrateDown undoes the previous migration.
type ConnParams ¶
ConnParams holds database server parameters.
type Connection ¶
type Connection interface {
MigrateUp()
MigrateDown()
}
Connection implements the app database handler.
Click to show internal directories.
Click to hide internal directories.