Documentation ¶
Overview ¶
Package web provides a simple web app framework.
Index ¶
- Variables
- func GetTx(ctx *ws.Context) db.Tx
- func Register(m Module)
- func Start()
- func UseTLS() bool
- type BaseModule
- func (a *BaseModule) Info() *BaseModule
- func (a *BaseModule) Init(rolekey []byte)
- func (a *BaseModule) Load(ctx *ws.Router) error
- func (a *BaseModule) RTx(ctx *ws.Context) error
- func (a *BaseModule) Role(id ID) (Role, error)
- func (a *BaseModule) RoleChecker(roles ...Role) func(*ws.Context) error
- func (a *BaseModule) Unload() error
- func (a *BaseModule) WTx(ctx *ws.Context) error
- type ID
- type Module
- type Role
- type Session
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrForbidden = ws.Status(http.StatusForbidden) ErrTooManyRequests = ws.Status(http.StatusTooManyRequests) ErrInvalidID = util.Error("无效的ID") ErrInvalidRole = util.Error("无效的角色") ErrInvalidSession = util.Error("无效的会话") )
Errors.
View Source
var ( Addr string CertFile string KeyFile string TokenKey []byte SessionMgr *token.Manager SessionAge = 60 * 60 * time.Second ReadTimeout = 10000 * time.Millisecond WriteTimeout = 10000 * time.Millisecond IdleTimeout = 10000 * time.Millisecond MinRequestDur = 500 * time.Millisecond MaxHeaderBytes = 10 * 1024 MaxBodyBytes = int64(1 * 1024 * 1024) Modules = []string{"sys"} )
Config options.
Functions ¶
Types ¶
type BaseModule ¶
type BaseModule struct { DB db.DB `json:"-"` Key string Name string Desc string // contains filtered or unexported fields }
BaseModule represents base module info.
func (*BaseModule) Init ¶
func (a *BaseModule) Init(rolekey []byte)
Init initializes the base module.
func (*BaseModule) RTx ¶
func (a *BaseModule) RTx(ctx *ws.Context) error
RTx returns a readonly tx handler.
func (*BaseModule) Role ¶
func (a *BaseModule) Role(id ID) (Role, error)
Role gets the user role by id.
func (*BaseModule) RoleChecker ¶
func (a *BaseModule) RoleChecker(roles ...Role) func(*ws.Context) error
RoleChecker returns a role checker.
type ID ¶
type ID uint64
ID represents a id.
func (ID) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*ID) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type Module ¶
type Module interface { // Info returns the module info. Info() *BaseModule // Load loads the module. Load(*ws.Router) error // Unload unloads the module. Unload() error // Role gets the user role by id. Role(id ID) (Role, error) }
Module represents a module.
type Role ¶
type Role uint64
Role represents a role.
func (Role) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Role) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type Session ¶
Session represents a session.
func GetSession ¶
GetSession gets the session from context.
func MakeSession ¶
MakeSession makes session from bytes.
Directories ¶
Path | Synopsis |
---|---|
Package db provides a generic interface around key/value databases.
|
Package db provides a generic interface around key/value databases. |
bolt
Package bolt implements the db interface with boltdb.
|
Package bolt implements the db interface with boltdb. |
Package sys mananges the users, groups and roles.
|
Package sys mananges the users, groups and roles. |
Package util provides some helpers.
|
Package util provides some helpers. |
Click to show internal directories.
Click to hide internal directories.