controller

package
v0.0.0-...-351ec1d Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HTTPSuccess 请求成功的时候 http code = 200
	// 当然也可以直接用http 包的200状态码
	HTTPSuccess = 200

	// APIError 业务code !=0的时候,默认API error code
	APIError = 500

	// APISuccess 业务成功code = 0,非0表示错误或异常
	APISuccess = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseController

type BaseController struct{}

BaseController 基础控制器

func (*BaseController) Error

func (ctrl *BaseController) Error(ctx *gin.Context, code int, message string, data interface{})

Error returns code,data,message if crtl response error.

func (*BaseController) Success

func (ctrl *BaseController) Success(ctx *gin.Context, message string, data interface{})

Success returns code,data,message if crtl response success.

type EmptyArray

type EmptyArray []struct{}

EmptyArray 用作空[]返回

type EmptyObject

type EmptyObject struct{}

EmptyObject 空对象{}格式返回

type HomeController

type HomeController struct {
	BaseController
}

HomeController home ctrl.

func (*HomeController) GetData

func (ctrl *HomeController) GetData(ctx *gin.Context)

GetData get homeLogic GetData.

func (*HomeController) Index

func (ctrl *HomeController) Index(ctx *gin.Context)

Index index.

func (*HomeController) Info

func (ctrl *HomeController) Info(ctx *gin.Context)

Info 接收url 路由参数id

func (*HomeController) LongAsync

func (ctrl *HomeController) LongAsync(ctx *gin.Context)

LongAsync When starting new Goroutines inside a middleware or handler, you SHOULD NOT use the original context inside it, you have to use a read-only copy.

func (*HomeController) SayHello

func (ctrl *HomeController) SayHello(c *gin.Context)

SayHello 测试http request然后调用grpc service. http://localhost:1338/say-hello/daheige

func (*HomeController) SetData

func (ctrl *HomeController) SetData(ctx *gin.Context)

SetData 模拟redis set data

func (*HomeController) Test

func (ctrl *HomeController) Test(ctx *gin.Context)

Test 测试panic

Jump to

Keyboard shortcuts

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