Documentation ¶
Index ¶
- Constants
- type Config
- type ConfigOption
- func DatabaseDriver(db DriverType) ConfigOption
- func DatabaseHost(host string) ConfigOption
- func DatabaseName(name string) ConfigOption
- func DatabasePass(pass string) ConfigOption
- func DatabasePort(port int) ConfigOption
- func DatabaseUser(user string) ConfigOption
- func DebugEnabled(enabled bool) ConfigOption
- func ListenAddr(addr string) ConfigOption
- func ListenPort(port int) ConfigOption
- func WithJWTSecret(secret string) ConfigOption
- func WithReadTimeout(timeout time.Duration) ConfigOption
- func WithWriteTimeout(timeout time.Duration) ConfigOption
- type DriverType
- type Server
Constants ¶
const ( SqliteMemoryUrl = "file::memory:?cache=shared" SqliteUrlFormat = "%s.db" MysqlUrlFormat = "%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=True&loc=Local" PostgresUrlFormat = "host=%s port=%d user=%s dbname=%s sslmode=disable password=%s" SqlServerUrlFormat = "sqlserver://%s:%s@%s:%d?database=%s" )
const ( SqliteMem DriverType = "sqlitemem" Sqlite = "sqlite" Postgres = "postgres" Mysql = "mysql" Sqlserver = "sqlserver" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // api JwtSecret string // contains filtered or unexported fields }
func NewConfig ¶
func NewConfig(opts ...ConfigOption) *Config
NewConfig returns a prepared Config struct with the given ConfigOption parameters modifying the state.
type ConfigOption ¶
type ConfigOption func(*Config)
func DatabaseDriver ¶
func DatabaseDriver(db DriverType) ConfigOption
DatabaseDriver sets the determined database you wish to use for persisting the data. Default: Sqlite Memory
func DatabaseHost ¶
func DatabaseHost(host string) ConfigOption
DatabaseHost sets the host address for the database you wish to connect to. Default: localhost
func DatabaseName ¶
func DatabaseName(name string) ConfigOption
DatabaseName sets the name of the database. Default: shiftr
func DatabasePass ¶
func DatabasePass(pass string) ConfigOption
DatabasePass sets the password to log into the database with. Default: none
func DatabasePort ¶
func DatabasePort(port int) ConfigOption
DatabasePort sets the port for the database you wish toc connect to. Default: none
func DatabaseUser ¶
func DatabaseUser(user string) ConfigOption
DatabaseUser sets the user to log into the database with. Default: none
func DebugEnabled ¶
func DebugEnabled(enabled bool) ConfigOption
DebugEnabled sets whether or not to enable Debug logging (sensitive data will be written to stdout!). Default: false
func ListenAddr ¶
func ListenAddr(addr string) ConfigOption
ListenAddr sets the port which the http server will accept connection. Default: localhost
func ListenPort ¶
func ListenPort(port int) ConfigOption
ListenPort sets the port which the http server will accept connection. Default: 8080
func WithJWTSecret ¶
func WithJWTSecret(secret string) ConfigOption
WithJWTSecret sets the JWT secret key to use for authentication. (CHANGE THE DEFAULT!) Default: changemeohgodplease
func WithReadTimeout ¶
func WithReadTimeout(timeout time.Duration) ConfigOption
WithReadTimeout sets the http Read Timeout. Default: time.Second * 10
func WithWriteTimeout ¶
func WithWriteTimeout(timeout time.Duration) ConfigOption
WithWriteTimeout sets the http Read Timeout. Default: time.Second * 10
type DriverType ¶
type DriverType string
func GetDriverType ¶
func GetDriverType(val string) DriverType
func (DriverType) String ¶
func (d DriverType) String() string
type Server ¶
func (*Server) Initialize ¶
Initialize starts the Server, connecting to the database specified in the configuration and setting up the defined API routes.