controllers

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2021 License: MIT Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(c *gin.Context, code int, msg ...string)

*

  • 失败时返回

func Error404

func Error404(c *gin.Context)

func Error500

func Error500(c *gin.Context)

func GenRequest

func GenRequest(c *gin.Context, request interface{}) (err error)

*

  • 将请求的body转换为request数据结构
  • @param c
  • @param request 传入request数据结构的指针 如 new(TestRequest)

func GetBannerList

func GetBannerList(c *gin.Context)

测试数据库服务示例

func HandleHello

func HandleHello(c *gin.Context)

hello示例

func HandleTest

func HandleTest(c *gin.Context)

request和response的示例 HandleTest godoc @Summary request和response的示例 @Description request和response的示例 @Tags snow @Accept json @Produce json @Param test body entities.TestRequest true "test request" @Success 200 {array} entities.TestResponse @Failure 400 {object} controllers.HTTPError @Failure 404 {object} controllers.HTTPError @Failure 500 {object} controllers.HTTPError @Router /test [post]

func HandleTestValidator added in v1.1.5

func HandleTestValidator(c *gin.Context)

validator的示例 HandleTestValidator godoc @Summary HandleTestValidator的示例 @Description HandleTestValidator的示例 @Tags snow @Accept json @Produce json @Param testValidator body entities.TestValidatorRequest true "example of validator" @Success 200 {array} entities.TestValidatorRequest @Failure 400 {object} controllers.HTTPError @Failure 404 {object} controllers.HTTPError @Failure 500 {object} controllers.HTTPError @Router /test_validator [post]

func ReadBody

func ReadBody(c *gin.Context) (body []byte, err error)

重复读取body

func Success

func Success(c *gin.Context, data interface{})

*

  • 成功时返回

Types

type HTTPError added in v1.2.0

type HTTPError struct {
	Code    int    `json:"code" example:"400"`
	Message string `json:"message" example:"status bad request"`
}

Jump to

Keyboard shortcuts

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