packer

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(p Packer)

Register 该调用是线程安全的

Types

type Gzip

type Gzip struct{}

func (*Gzip) EnPacket

func (g *Gzip) EnPacket(p []byte) ([]byte, error)

func (*Gzip) Scheme

func (g *Gzip) Scheme() string

func (*Gzip) UnPacket

func (g *Gzip) UnPacket(p []byte) ([]byte, error)

type Packer

type Packer interface {
	Scheme() string
	// EnPacket 装包
	EnPacket(p []byte) ([]byte, error)
	// UnPacket 拆包
	UnPacket(p []byte) ([]byte, error)
}

Packer 负责解包/拆包的实例要实现的接口 获得数据是经过json encode之后的Body,Header不会被发送到此处理 默认实现text&gzip

func Get

func Get(scheme string) Packer

Get 该调用是线程安全的

type Text

type Text struct{}

Text 注意:text类型的压缩器只是提供给client&server 的一个提示,client&server的代码应该针对此特殊处理,真实调用会导致panic

func (Text) EnPacket

func (t Text) EnPacket(p []byte) ([]byte, error)

func (Text) Scheme

func (t Text) Scheme() string

func (Text) UnPacket

func (t Text) UnPacket(p []byte) ([]byte, error)

Jump to

Keyboard shortcuts

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