rest

package
v0.0.0-...-e8da740 Latest Latest
Warning

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

Go to latest
Published: May 21, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const TokenExpireDuration = time.Hour * 2

TokenExpireDuration expireDuration

Variables

View Source
var MySecret = []byte("#1024Helper")

MySecret ...

Functions

func AuthCros

func AuthCros() gin.HandlerFunc

AuthCros ....

func Bind

func Bind(c *gin.Context, req interface{}) error

Bind check bind uri

func GenToken

func GenToken(name string) (string, error)

GenToken 生成JWT

func HTTPResponse

func HTTPResponse(c *Context, httpCode *int, err *error, data *interface{})

HTTPResponse 统一返回格式

func IsNil

func IsNil(obj interface{}) bool

IsNil check obj of interface{} is nil

Types

type Context

type Context struct {
	context.Context

	Operator *Operator
	// contains filtered or unexported fields
}

Context context define

func NewContext

func NewContext(c *gin.Context) *Context

NewContext new context

type HTTPServer

type HTTPServer struct {
	// contains filtered or unexported fields
}

HTTPServer ...

func NewHTTPServer

func NewHTTPServer(conf *HttpConf) *HTTPServer

NewHTTPServer new HTTPServer

func (*HTTPServer) Start

func (s *HTTPServer) Start(ctx *context.Context, register httpRegisterFunc) error

Start start grpc service

type HttpConf

type HttpConf struct {
	Listen  string
	Actived bool
	PProf   bool
}

HTTPConf config define

type ListData

type ListData struct {
	TotalOption
	List interface{} `json:"list"`
}

ListData ...

func NewListData

func NewListData(opt PageOption, total int64, list interface{}) *ListData

NewListData fill data

type Operator

type Operator struct {
	jwt.StandardClaims
	Name string
}

Operator ...

type PageOption

type PageOption struct {
	PageIndex int    `form:"pageIndex"`
	PageSize  int    `form:"pageSize"`
	Sort      string `form:"sort"` //asc or desc
}

PageOption ...

func (*PageOption) Check

func (opt *PageOption) Check()

Check ...

type ResultReply

type ResultReply struct {
	Result bool        `json:"result"`
	Msg    interface{} `json:"msg"`
}

ResultReply ...

func (*ResultReply) SetResult

func (r *ResultReply) SetResult(err error)

SetResult ...

type TotalOption

type TotalOption struct {
	PageIndex  int   `json:"pageIndex"`
	PageSize   int   `json:"pageSize"`
	TotalCount int64 `json:"totalCount"`
	TotalPage  int   `json:"totalPage"`
}

TotalOption ...

Jump to

Keyboard shortcuts

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