endpoint

package module
v0.0.0-...-d02e59b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2018 License: MIT Imports: 3 Imported by: 6

Documentation

Index

Constants

View Source
const (
	DB_USER_KEY     = "USER"
	DB_PWD_KEY      = "PASSWORD"
	DB_NAME_KEY     = "NAME"
	DB_SSL_MODE_KEY = "SSL_MODE"
	DB_VERSION      = "VERSION"
)

Database environment variable keysuffixes

View Source
const (
	DEFAULT_POSTGRES_PORT     = "5432"
	DEFAULT_POSTGRES_SSL_MODE = "disable"
	DEFAULT_POSTGRES_DATABASE = "postgres"
	POSTGRES_PROTOCOL         = "tcp"
)

PostgreSQL default values

View Source
const (
	DEFAULT_MYSQL_PORT     = "3306"
	DEFAULT_MYSQL_PROTOCOL = "tcp"
)

MySQL default values

View Source
const (
	PORT     = "PORT"
	HOST     = "HOST"
	PROTOCOL = "PROTOCOL"
	USER     = "USER"
	DATABASE = "DATABASE"
)

ServerAddr environment variable keysuffixes

View Source
const (
	DEFAULT_SERVER_PROTOCOL = "http"
	DEFAULT_SERVER_HOST     = "localhost"
)

ServerAddr default values

View Source
const (
	DEFAULT_SQLITE_DRIVER = "sqlite3"
)

SQLite default values

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnInfo

type ConnInfo struct {
	DriverName string `json:"driverName"`
	ConnStr    string `json:"connStr"`
}

ConnInfo Information needed to connect to a database

type MySQLConfig

type MySQLConfig struct {
	ServerAddr
	User             string `json:"username"`
	Password         string `json:"password"`
	Database         string `json:"database"`
	ConnectionParams string `json:"connectionParams"`
}

MySQLConfig Configuration info for a MySQL db

func NewMySQLConfig

func NewMySQLConfig(name string) MySQLConfig

NewMySQLConfig Creates a new MySQLConfig from environment variables

func (MySQLConfig) ConnInfo

func (my MySQLConfig) ConnInfo() ConnInfo

ConnInfo Gets the connection information

func (MySQLConfig) Connect

func (my MySQLConfig) Connect() (*sql.DB, error)

Connect Attempts to connect to a MySQL database. Requires a driver!

type PGConfig

type PGConfig struct {
	ServerAddr
	User     string `json:"username"`
	Password string `json:"password"`
	Database string `json:"database"`
	SSLMode  string `json:"sslMode"`
}

PGConfig Connection info for a postgres database

func NewPGConfig

func NewPGConfig(name string) PGConfig

NewPGConfig Creates a new PGConfig by reading from environment variables

func (PGConfig) ConnInfo

func (pg PGConfig) ConnInfo() ConnInfo

ConnInfo Creates and returns connection info from a PGConfig

func (PGConfig) Connect

func (pg PGConfig) Connect() (*sql.DB, error)

Connect Attempts to connect to a postgres database. Requires a driver!

type SQLConfig

type SQLConfig interface {
	Connect() (*sql.DB, error)
	ConnInfo() ConnInfo
}

SQLConfig Interface for database configuration and connection

type SQLiteConfig

type SQLiteConfig struct {
	DriverVersion string `json:"driverVersion"`
	File          string `json:"file"`
}

SQLiteConfig Configuration info for a SQLite db

func NewSQLiteConfig

func NewSQLiteConfig(name string) SQLiteConfig

NewSQLiteConfig Creates a new SQLconfig by reading from environment variables

func (SQLiteConfig) ConnInfo

func (lite SQLiteConfig) ConnInfo() ConnInfo

ConnInfo Gets the connection information

func (SQLiteConfig) Connect

func (lite SQLiteConfig) Connect() (*sql.DB, error)

Connect Connects to a sqlite database. Requires a driver!

type ServerAddr

type ServerAddr struct {
	Host     string `json:"host,omitempty"`
	Port     string `json:"port,omitempty"`
	Protocol string `json:"protocol,omitempty"`
}

ServerAddr Connection info for a server

func NewServerAddr

func NewServerAddr(name string) ServerAddr

NewServerAddr Creates a new ServerAddr by checking environment varialbes whose keys are derived from the supplied name

func (ServerAddr) Address

func (server ServerAddr) Address() string

Address Gets the host:port concatentaion of the ServerAddr

func (ServerAddr) Network

func (server ServerAddr) Network() string

Network Gets the ServerAddr protwork based on the protocol

func (ServerAddr) ToURL

func (server ServerAddr) ToURL(route string) string

ToURL Accepts a route as a parameter and turns the route + ServerAddr to a full url

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL