Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsAdmin ¶
func AsAdmin(handler AdminHandler) gin.HandlerFunc
AsAdmin wraps the handler with the AdminContext
func AsAdminOrUser ¶
func AsAdminOrUser(handler UserHandler) gin.HandlerFunc
AsAdminOrUser allows both admin and user to access the handler
func AsUser ¶
func AsUser(handler UserHandler) gin.HandlerFunc
AsUser wraps the handler with the user context. User can be authorized by xPub or accessKey
Types ¶
type AdminHandler ¶
type AdminHandler = func(c *gin.Context, _ *reqctx.AdminContext)
AdminHandler is the handler for admin's requests
type GroupType ¶
type GroupType int
GroupType is a type of group
const ( // GroupRoot is the root group without no prefix and no auth middleware GroupRoot GroupType = iota // GroupOldAPI is the group with the old API prefix and auth middleware GroupOldAPI // GroupAPI is the group with the API prefix and auth middleware GroupAPI // GroupTransactionCallback is the group with the transaction callback prefix and callback token middleware (no auth middleware) GroupTransactionCallback )
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is a struct helps to group routes with proper middleware
func NewManager ¶
NewManager creates a new Grouper
func (*Manager) Get ¶
func (mg *Manager) Get(endpointType GroupType) *gin.RouterGroup
Get returns the group with the given endpointType
func (*Manager) Group ¶
func (mg *Manager) Group(endpointType GroupType, relativePath string, middlewares ...gin.HandlerFunc) *gin.RouterGroup
Group creates a new group with the given endpointType and relativePath and optional list checkers, e.g. middleware.RequireSignature
type UserHandler ¶
type UserHandler = func(c *gin.Context, userContext *reqctx.UserContext)
UserHandler is the handler for the user
type UserHandlerWithXPub ¶
type UserHandlerWithXPub = func(c *gin.Context, userContext *reqctx.UserContext, xpub string)
UserHandlerWithXPub is the handler for the user who has authorized using xPub