handler

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapF

func WrapF(f HandlerFunc) gin.HandlerFunc

WrapF is a helper function for wrapping handler.HandlerFunc and returns a Gin middleware.

func WrapFD

WrapFD is a helper function for wrapping handler.HandlerDataFunc and returns a Gin middleware.

func WrapH

func WrapH(h Handler) gin.HandlerFunc

WrapH is a helper function for wrapping handler.Handler and returns a Gin middleware.

Types

type Duration

type Duration time.Duration

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() (b []byte, err error)

type Handler

type Handler interface {
	Validate(c *gin.Context) error
	Handle(c *gin.Context, log logrus.FieldLogger) (any, error)
}

The Handler is an abstract of handle request

type HandlerDataFunc

type HandlerDataFunc func(c *gin.Context, log logrus.FieldLogger) (any, error)

The HandlerDataFunc type is an adapter to allow the use of ordinary functions as HTTP handlers. If f is a function with the appropriate signature, HandlerDataFunc(f) is a Handler that calls f.

type HandlerFunc

type HandlerFunc func(c *gin.Context, log logrus.FieldLogger) error

The HandlerFunc type is an adapter to allow the use of ordinary functions as HTTP handlers. If f is a function with the appropriate signature, HandlerFunc(f) is a Handler that calls f.

type Pagination

type Pagination struct {
	// Page is the page number, starting from 1.
	// Required: true, Minimum value: 1
	Page int `json:"page" binding:"required,gte=1"`
	// PerPage is the number of items per page.
	// Required: true, Minimum value: 1, Maximum value: 300
	PerPage int `json:"perPage" binding:"required,gte=1,lte=300"`
}

Pagination represents the pagination parameters for a request.

type Response

type Response struct {
	Success   bool      `json:"success" yaml:"success"`
	Code      string    `json:"code" yaml:"code"`
	Message   string    `json:"message" yaml:"message"`
	Data      any       `json:"data,omitempty" yaml:"data,omitempty"`
	TraceID   string    `json:"traceID,omitempty" yaml:"traceID,omitempty"`
	StartTime time.Time `json:"startTime,omitempty" yaml:"startTime,omitempty"`
	EndTime   time.Time `json:"endTime,omitempty" yaml:"endTime,omitempty"`
	CostTime  Duration  `json:"costTime,omitempty" yaml:"costTime,omitempty"`
}
type Search struct {
	// Keyword is the keyword to search for.
	// Optional: true
	Keyword string `json:"keyword,omitempty"`
}

Search represents the search criteria for a request.

Directories

Path Synopsis
api
debug

Jump to

Keyboard shortcuts

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