webserver

package
v0.0.0-...-bdc8d50 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StatusOK = add(200, "StatusOK")

	StatusBadRequest   = add(4000, "请求错误")
	StatusParamInvalid = add(4001, "参数错误")
	StatusUnauthorized = add(4010, "未认证")
	StatusTokenExpires = add(4011, "认证过期")
	StatusAccessDenied = add(4012, "权限不足")
	StatusNotFound     = add(4040, "路由错误")

	StatusServerError        = add(5000, "服务器错误")
	StatusDatabaseErr        = add(5200, "数据库操作失败")
	StatusDataNotFound       = add(5201, "未查询到数据")
	StatusServiceUnreachable = add(5300, "服务暂不可用")
	StatusServiceTimeout     = add(5301, "服务调用超时")
)

commom ecode

Functions

This section is empty.

Types

type Code

type Code int32

Code is an int error code spec

func Int

func Int(e int) Code

Int parse code int to error

func String

func String(e string) Code

String parse code string to error

func (Code) Error

func (e Code) Error() string

Error .

func (Code) Int

func (e Code) Int() int

Int .

func (Code) WebError

func (e Code) WebError(v interface{}) *WebError

WebError .

type Request

type Request struct {
}

Request .

type Response

type Response struct {
	ID   string      `json:"id"`
	Code Code        `json:"code,omitempty"`
	Data interface{} `json:"data,omitempty"`
}

Response .

type WebError

type WebError struct {
	ID      string `json:"id"`
	Code    Code   `json:"code"`
	Message string `json:"message"`
}

WebError .

func NewWebError

func NewWebError(code Code, message interface{}) *WebError

NewWebError .

func (*WebError) Error

func (e *WebError) Error() string

Error .

Jump to

Keyboard shortcuts

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