controller

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAge int = 600
View Source
const (
	TopicSession string = "session"
)

Variables

This section is empty.

Functions

func DeleteAllSession added in v1.0.1

func DeleteAllSession()

func DeleteSession

func DeleteSession(token string)

func DeleteSessionByUserId

func DeleteSessionByUserId(userId string)

func GetRequestBody

func GetRequestBody(c *gin.Context, body interface{}) error

func SessionMiddle

func SessionMiddle() gin.HandlerFunc

func UpdateSession

func UpdateSession(token string)

Types

type Controller

type Controller interface {
	Group() *gin.RouterGroup

	GET(relativePath string, handler HandlerFunc, middle ...gin.HandlerFunc)
	POST(relativePath string, handler HandlerFunc, middle ...gin.HandlerFunc)
	PUT(relativePath string, handler HandlerFunc, middle ...gin.HandlerFunc)
	DELETE(relativePath string, handler HandlerFunc, middle ...gin.HandlerFunc)
	PATCH(relativePath string, handler HandlerFunc, middle ...gin.HandlerFunc)
	HEAD(relativePath string, handler HandlerFunc, middle ...gin.HandlerFunc)
	OPTIONS(relativePath string, handler HandlerFunc, middle ...gin.HandlerFunc)

	GETWithSession(relativePath string, handler HandlerFunc, middle ...gin.HandlerFunc)
	POSTWithSession(relativePath string, handler HandlerFunc, middle ...gin.HandlerFunc)
	PUTWithSession(relativePath string, handler HandlerFunc, middle ...gin.HandlerFunc)
	DELETEWithSession(relativePath string, handler HandlerFunc, middle ...gin.HandlerFunc)
	PATCHWithSession(relativePath string, handler HandlerFunc, middle ...gin.HandlerFunc)
	HEADWithSession(relativePath string, handler HandlerFunc, middle ...gin.HandlerFunc)
	OPTIONSWithSession(relativePath string, handler HandlerFunc, middle ...gin.HandlerFunc)
}

func New

func New(prefix string) (Controller, error)

type HandlerFunc

type HandlerFunc func(context *gin.Context, session *Session) (interface{}, error)

type Response

type Response struct {
	Result bool        `json:"result"`
	Error  string      `json:"error"`
	Data   interface{} `json:"data,omitempty"`
}

type Session

type Session struct {
	Token    string      `json:"token"`
	UserId   string      `json:"userId"`
	Username string      `json:"username"`
	Ip       string      `json:"ip"`
	Context  interface{} `json:"context,omitempty"`
	// contains filtered or unexported fields
}

func CreateSession

func CreateSession(userId string, username string, ip string, context interface{}) (*Session, error)

func GetSession

func GetSession(token string) (*Session, error)

Jump to

Keyboard shortcuts

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