common

package
v0.0.0-...-3ea1b23 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrZeroExpireSecond               = New(http.StatusBadRequest, 1, "zero expire time")
	ErrZeroExpireCount                = New(http.StatusBadRequest, 2, "zero expire count")
	ErrExpireSecondGreaterThanMonth   = New(http.StatusBadRequest, 3, "expire minute greater than a month")
	ErrExpireCountGreaterThanMaxCount = New(http.StatusBadRequest, 4, "expire count greater than max count")
	ErrEmptyContent                   = New(http.StatusBadRequest, 5, "empty content")
	ErrEmptyLang                      = New(http.StatusBadRequest, 6, "empty lang")
	ErrInvalidLang                    = New(http.StatusBadRequest, 7, "invalid lang")
	ErrWrongParamType                 = New(http.StatusBadRequest, 8, "wrong param type")
	ErrInvalidKeyLength               = New(http.StatusBadRequest, 9, "invalid key length")
	ErrInvalidKeyFormat               = New(http.StatusBadRequest, 10, "invalid key format")

	ErrUnauthorized = New(http.StatusUnauthorized, 1, "unauthorized")

	ErrWrongPassword = New(http.StatusForbidden, 1, "wrong password")

	ErrNoRouterFounded = New(http.StatusNotFound, 1, "no router founded")
	ErrRecordNotFound  = New(http.StatusNotFound, 2, "record not found")

	ErrQueryDBFailed = New(http.StatusInternalServerError, 1, "query from db failed")
	ErrSaveFailed    = New(http.StatusInternalServerError, 2, "save failed")
)

Functions

func Beat

func Beat(context *gin.Context)

Beat godoc @Summary 心跳检测 @Description 心跳检测 @Tags Common @Produce json @Param method query string true "方法" Enums("beat") @Success 200 {object} common.Response @Failure default {object} common.ErrorResponse @Router / [get]

func JSON

func JSON(context *gin.Context, response IResponse)

func NotFoundHandler

func NotFoundHandler(context *gin.Context)

Types

type ErrorResponse

type ErrorResponse struct {
	*Response
	Message string `json:"message" example:"ok"`
}

func New

func New(code int, index int, message string) *ErrorResponse

func (*ErrorResponse) Abort

func (response *ErrorResponse) Abort(context *gin.Context)

func (*ErrorResponse) Error

func (response *ErrorResponse) Error() string

type IResponse

type IResponse interface {
	GetHttpStatusCode() int
}

type Response

type Response struct {
	Code int `json:"code" example:"200"`
}

func (*Response) GetHttpStatusCode

func (response *Response) GetHttpStatusCode() int

Jump to

Keyboard shortcuts

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