route

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2020 License: Apache-2.0 Imports: 30 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ContentDispositionHeaderKey         = "Content-Disposition"
	ContentDispositionHeaderValueFormat = `attachment; filename="%s"`
)

header相关

Functions

func MakeCookie

func MakeCookie(userID int) (cookie http.Cookie, err error)

MakeCookie 新建令牌

func Register

func Register(v interface{})

Register 注册

func StartServer

func StartServer(port int) error

StartServer 开启服务

Types

type AddResult

type AddResult struct {
	ID int `json:"id"` // 新纪录ID
}

AddResult 添加记录后的结果

type Checker

type Checker interface {
	Check(context.Context) error
}

Checker 检查接口

type Content

type Content struct {
	ContentLength int64             `json:"-"`
	ContentType   string            `json:"-"`
	ContentReader io.Reader         `json:"-"`
	ExtraHeaders  map[string]string `json:"-"`
}

Content 内容

func MakeContentFromBuffer

func MakeContentFromBuffer(filename string, buf *bytes.Buffer) Content

MakeContentFromBuffer 新建内容

type File

type File struct {
}

File 用来标志结构体的文件上传/下载属性

type Filter

type Filter interface {
	Filter() interface{}
}

Filter 过滤器

type Group

type Group struct {
}

Group 分组

type HandlerFunc

type HandlerFunc = func(context.Context, Param) (Result, error)

HandlerFunc 处理函数 使用别名,可以互相替换,但是不能添加方法 使用类型,不可以互相替换,需要转型,但是可以添加方法

type Limiter

type Limiter struct {
}

Limiter 限流器

type Method

type Method struct {
}

Method 方法

type Newer

type Newer interface {
	New() interface{}
}

Newer 新建

type Param

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

Param 参数

func (*Param) Parse

func (p *Param) Parse(ctx context.Context, v interface{}) error

Parse 解析

func (*Param) ParseMultipartForm

func (p *Param) ParseMultipartForm(maxFileSize int64, v interface{}) ([]byte, error)

ParseMultipartForm 解析内容

type Result

type Result struct {
	utilerrors.Error

	Data interface{} `json:"data"` // 正常返回时的数据

	// 给登陆接口使用
	CookieAfterLogin int `json:"-"` // 登陆时需要设置登陆态的用户信息

	// 请求ID,在请求到来时生成,处理过程传递,返回时一并返回
	RequestID string `json:"requestID"` // uuid

	// 下载内容时使用
	Content
}

Result 结果

func (*Result) PresentData

func (r *Result) PresentData(v interface{}) error

PresentData 用具体结构体展现数据

type Router

type Router struct {
	*gin.Engine
}

Router 路由

func DefaultRouter

func DefaultRouter() *Router

DefaultRouter 获取默认路由

func NewRouter

func NewRouter() *Router

NewRouter 新建路由

func (*Router) Register

func (r *Router) Register(v interface{})

Register 注册结构体 结构体名字作为路径的第一部分,路径后面部分由可导出方法名映射来

Jump to

Keyboard shortcuts

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