server

package
v0.0.0-...-9dae437 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2021 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
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

type Server struct {
	DB     *gorm.DB
	API    *echo.Echo
	Config *Config
}

func New

func New() *Server

func (*Server) Initialize

func (s *Server) Initialize(config *Config) error

Initialize starts the Server, connecting to the database specified in the configuration and setting up the defined API routes.

func (*Server) Run

func (s *Server) Run()

Jump to

Keyboard shortcuts

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