Documentation ¶
Overview ¶
PolarisConfig defined the system configuration and router mapping. It's an interface to the end user to enable them to extend the capability.
Package polaris provides the major features to the end user. So far, it's a customized version of https://github.com/go-martini/martini/ with other packages. It proovides a solid project start in golang.
UserModel defined a user model. It's an interface to the end user to enable them to extend the capability.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateAnonymousUser ¶
func GenerateAnonymousUser() sessionauth.User
GetAnonymousUser should generate an anonymous user model for all sessions. This should be an unauthenticated 0 value struct.
Types ¶
type Config ¶
type Config interface { LoadConfig() bool GetBasicConfig() *PolarisConfig RoterMap(app *PolarisApplication) bool }
Config is the interface to cental config object
type DBConfig ¶
type DBConfig struct { // Type is the type of database Type string // Driver is the driver name of current database, so far, Polaris support : mysql/gomysql/postgres/sqlite/adodb Driver string // Host is the host name of current database server Host string // Port is the port number of current database server Port string // Database is the database name of current database Database string // User is the user name to access current database User string // Password is the password of current user Password string // Verbose is flag to output SQL statement into log or not Verbose bool // LogFile is the log file name for SQL statement. LogFile string // contains filtered or unexported fields }
func (*DBConfig) MartiniHandler ¶
get handler for Martini.Use function
type PolarisApplication ¶
type PolarisApplication struct { *martini.Martini martini.Router // Config is an user provided object to store relevant information Config Config // Store is a internal variable to store the RediStore object Store *redistore.RediStore // DbEngine is the pointer to a global query engine DbEngine *DBEngine }
PolarisApplication represents a Martini with some reasonable defaults same as the original ClassicMartini.
func NewApp ¶
func NewApp(cfg Config, newUser func() sessionauth.User) *PolarisApplication
NewApp creates a application object with some basic default middleware. It's based on ClassicMartini. Classic also maps martini.Routes as a service.
func (*PolarisApplication) Close ¶
func (app *PolarisApplication) Close() bool
func (*PolarisApplication) RotateLog ¶
func (app *PolarisApplication) RotateLog() bool
func (*PolarisApplication) RunApp ¶
func (app *PolarisApplication) RunApp() bool
type PolarisConfig ¶
type PolarisConfig struct { // DirStatic is the default folder name where the public resouces(e.g, image, css, js and etc) are putted into DirStatic string // DirTemplate is the folder name where the template files located in DirTemplate string // DirLog is the folder name where the log files located in DirLog string // TempExtension is the extension name of template files TempExtension string // TempEncoding is the encoding name of the templates files TempEncoding string // SessionStore is the store type of the session. it can be cookie or redis so far SessionStore string // SessionName is the default session name for cookie to store session id SessionName string // SessionMask is a mask code to the cookie of session id SessionMask string // Redis is the option set for redis connection Redis *RedisConfig // DBType is the datbase type. So far, it can be mysql/gomysql/postgres/sqlite/adodb DBType string // Database is the configuration items for database Database DBConfig // Port is the port number current server listening on Port int // CfgFile is a reference pointer to the config file CfgFile string // CfgHandle is a reference pointer to the config file CfgHandle *goconfig.ConfigFile // LogFile is the file name of current log LogFile string // LogHandle is the log handl LogHandle *os.File // contains filtered or unexported fields }
PolarisConfig is the struct to define configuration items
func (*PolarisConfig) GetBasicConfig ¶
func (cfg *PolarisConfig) GetBasicConfig() *PolarisConfig
func (*PolarisConfig) LoadConfig ¶
func (cfg *PolarisConfig) LoadConfig() bool
LoadConfig creates a config object by specified config file.
func (*PolarisConfig) RoterMap ¶
func (config *PolarisConfig) RoterMap(app *PolarisApplication) bool
RoterMap provides a interface to the end user to empower them to customize their own router
type RedisConfig ¶
type RedisConfig struct { // Size is the maximum number of idle connections Size int // Network is the communication protocal of redis Network string // Address is the acctual adress of the redis server hostname + port Address string // Password is the default password of the connection Password string // DB is the default database in redis DB string }
RedisConfig is the struct to define configuration items for redis
type UserModel ¶
type UserModel struct { Uid int64 `form:"Uid" db:"N_UID"` RoleID int `form:"-" db:"N_ROLE_ID"` Grp01 int `form:"-" db:"N_GRP1"` Grp02 int `form:"-" db:"N_GRP2"` InUse int `form:"-" db:"N_INUSE"` UserID string `form:"UserID" db:"C_UID"` Password string `form:"Password" db:"C_PWD"` Email string `form:"-" db:"C_EMAIL"` HomeURL string `form:"-" db:"C_HOME"` Language string `form:"-" db:"C_LANGUAGE"` Org01 string `form:"-" db:"C_ORG1"` Org02 string `form:"-" db:"C_ORG2"` Org03 string `form:"-" db:"C_ORG3"` Org04 string `form:"-" db:"C_ORG4"` Preference string `form:"-" db:"C_PREFERENCE"` // contains filtered or unexported fields }
UserModel can be any struct that represents a user in my system
func (*UserModel) GetById ¶
GetById will populate a user object from a database model with a matching id.
func (*UserModel) GetByNamePass ¶
GetByNamePass will populate a user object from a database model with a matching name and password.
func (*UserModel) IsAuthenticated ¶
func (*UserModel) Login ¶
func (u *UserModel) Login()
Login will preform any actions that are required to make a user model officially authenticated.