result

package
v1.0.1-0...-540a35a Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OK                    = &CodeWrapper{Code: "OK", HttpStatus: http.StatusOK, Description: "ok"}
	BAD_REQUEST           = &CodeWrapper{Code: "BAD_REQUEST", HttpStatus: http.StatusBadRequest, Description: "bad request"}
	NEED_SHARE_CODE       = &CodeWrapper{Code: "NEED_SHARE_CODE", HttpStatus: http.StatusUnauthorized, Description: "share code required"}
	SHARE_CODE_ERROR      = &CodeWrapper{Code: "SHARE_CODE_ERROR", HttpStatus: http.StatusUnauthorized, Description: "share code error"}
	LOGIN                 = &CodeWrapper{Code: "LOGIN", HttpStatus: http.StatusUnauthorized, Description: "not login"}
	USER_DISABLED         = &CodeWrapper{Code: "USER_DISABLED", HttpStatus: http.StatusForbidden, Description: "user disabled"}
	UNAUTHORIZED          = &CodeWrapper{Code: "UNAUTHORIZED", HttpStatus: http.StatusUnauthorized, Description: "unauthorized"}
	NOT_FOUND             = &CodeWrapper{Code: "NOT_FOUND", HttpStatus: http.StatusNotFound, Description: "404 not found"}
	RANGE_NOT_SATISFIABLE = &CodeWrapper{Code: "RANGE_NOT_SATISFIABLE", HttpStatus: http.StatusRequestedRangeNotSatisfiable, Description: "range not satisfiable"}
	NOT_INSTALLED         = &CodeWrapper{Code: "NOT_INSTALLED", HttpStatus: http.StatusInternalServerError, Description: "application not installed"}
	SERVER                = &CodeWrapper{Code: "SERVER", HttpStatus: http.StatusInternalServerError, Description: "server error"}
	UNKNOWN               = &CodeWrapper{Code: "UNKNOWN", HttpStatus: http.StatusInternalServerError, Description: "server unknow error"}
)
View Source
var (
	DB_ERROR_DUPLICATE_KEY  = "Error 1062: Duplicate entry"
	DB_ERROR_NOT_FOUND      = "record not found"
	DB_TOO_MANY_CONNECTIONS = "Error 1040: Too many connections"
	DB_BAD_CONNECTION       = "driver: bad connection"
)

db error.

Functions

func FetchHttpStatus

func FetchHttpStatus(code string) int

Types

type CodeWrapper

type CodeWrapper struct {
	Code        string
	HttpStatus  int
	Description string
}

type WebResult

type WebResult struct {
	Code string      `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

func BadRequest

func BadRequest(format string, v ...interface{}) *WebResult

func BadRequestI18n

func BadRequestI18n(request *http.Request, item *i18n.Item, v ...interface{}) *WebResult

func ConstWebResult

func ConstWebResult(codeWrapper *CodeWrapper) *WebResult

func CustomWebResult

func CustomWebResult(codeWrapper *CodeWrapper, description string) *WebResult

func CustomWebResultI18n

func CustomWebResultI18n(request *http.Request, codeWrapper *CodeWrapper, item *i18n.Item, v ...interface{}) *WebResult

func NotFound

func NotFound(format string, v ...interface{}) *WebResult

func Server

func Server(format string, v ...interface{}) *WebResult

sever inner error

func Unauthorized

func Unauthorized(format string, v ...interface{}) *WebResult

func (*WebResult) Error

func (this *WebResult) Error() string

Jump to

Keyboard shortcuts

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