router

package
v0.0.32 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UsernameParam = "username"
	UUIDParam     = "uuid"
)
View Source
const (
	RootRoute                     = "/"
	EchoRoute                     = "/echo"
	LoginRoute                    = "/login"
	RegisterRoute                 = "/register"
	ChallengeRoute                = "/challenge"
	AccountPasswordRoute          = "/account/password"
	LogsRoute                     = "/logs"
	UserRoute                     = "/user"
	LogsUserRoute                 = LogsRoute + UserRoute
	DateRoute                     = "/date"
	LogsDateRoute                 = LogsRoute + DateRoute
	UserUUIDRoute                 = "/user/uuid"
	UserUUIDWithParamsRoute       = UserUUIDRoute + "/:" + UsernameParam
	UsernameByUUIDRoute           = "/user/username"
	UsernameByUUIDWithParamsRoute = UsernameByUUIDRoute + "/:" + UUIDParam
)
View Source
const (
	AuthorizationHeader = "Authorization"
)
View Source
const (
	SessionVariale = "SESSION"
)

Variables

View Source
var UnauthorizedResult = Result{Succeed: false, Message: "unauthorized"}

Functions

func Bearer added in v0.0.23

func Bearer(tok string) string

func New

func New(opts ...Option) *gin.Engine

func NewDefault

func NewDefault(t *testing.T, db *gorm.DB) (expect *httpexpect.Expect, closeFunc func())

Types

type Option

type Option func(r *Router)

func WithController added in v0.0.19

func WithController(c *controller.Controller) Option

func WithEngine

func WithEngine(e *gin.Engine) Option

type Result added in v0.0.19

type Result struct {
	Succeed bool   `json:"succeed"`
	Message string `json:"msg"`
}

func InternalServerError added in v0.0.19

func InternalServerError(err error) Result

func SucceedResult added in v0.0.23

func SucceedResult(msg string) Result

type Router

type Router struct {
	*gin.Engine
	C *controller.Controller
}

func (*Router) Authorize added in v0.0.23

func (r *Router) Authorize(ctx *gin.Context)

func (*Router) Challenge added in v0.0.23

func (r *Router) Challenge(ctx *gin.Context)

func (*Router) GetLogByDate added in v0.0.26

func (r *Router) GetLogByDate(ctx *gin.Context)

GET /logs/date

func (*Router) GetLogByUser added in v0.0.26

func (r *Router) GetLogByUser(ctx *gin.Context)

GET /logs/username

func (*Router) GetLogs added in v0.0.26

func (r *Router) GetLogs(ctx *gin.Context)

GET /logs

func (*Router) Login added in v0.0.19

func (r *Router) Login(ctx *gin.Context)

POST /login

func (*Router) Register added in v0.0.21

func (r *Router) Register(ctx *gin.Context)

func (*Router) UpdatePassword added in v0.0.23

func (r *Router) UpdatePassword(ctx *gin.Context)

func (*Router) UserByUsername added in v0.0.23

func (r *Router) UserByUsername(ctx *gin.Context)

func (*Router) UsernameByUUID added in v0.0.31

func (r *Router) UsernameByUUID(ctx *gin.Context)

type Token added in v0.0.19

type Token struct {
	JWT string `json:"jwt"`
}

Jump to

Keyboard shortcuts

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