base

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MdContextKey             = "md"         //gin context里设置的md key
	RequestIdInMdKey         = "requestId"  //md里设置的requestId key
	RequestIdInHttpHeaderKey = "request-id" //请求头 requestId
	SessionCookieName        = "s-token"    //session cookie name
	SessionContextKey        = "s-ctx"      //session context key
)
View Source
const (
	//SuccessCode 成功
	SuccessCode = 200
	//FailCode 失败
	FailCode = 500
)

Variables

This section is empty.

Functions

func Redirect

func Redirect(ctx *gin.Context, templateName string)

func RenderHtml

func RenderHtml(ctx *gin.Context, templateName string)

func RenderHtmlWithData

func RenderHtmlWithData(ctx *gin.Context, templateName string, data interface{})

func RenderJson

func RenderJson(ctx *gin.Context, code int, msg string, data interface{})

func RenderJsonFail

func RenderJsonFail(ctx *gin.Context, err error)

func RenderJsonSuccess

func RenderJsonSuccess(ctx *gin.Context, data interface{})

Types

type Error

type Error struct {
	Code int    `json:"code,omitempty"` //错误码
	Msg  string `json:"msg,omitempty"`  //错误信息
}

func NewError

func NewError(code int) *Error

func NewMsgError

func NewMsgError(message string) *Error

func (Error) Error

func (err Error) Error() string

func (Error) String

func (err Error) String() string

type ResponseEntity

type ResponseEntity struct {
	Code int         `json:"code,omitempty"`
	Msg  string      `json:"msg,omitempty"`
	Data interface{} `json:"data,omitempty"`
}

Jump to

Keyboard shortcuts

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