ihttp

package module
v0.0.0-...-92c526b Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 13 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MethodGet     = "get"
	MethodPost    = "post"
	MethodOptions = "options"
)
View Source
var (
	MsgTypeText = websocket.TextMessage
	MsgTypeBin  = websocket.BinaryMessage
)

Functions

func Get

func Get(url string, data map[string]string, header map[string]string) ([]byte, error)

func Post

func Post(url string, data map[string]string, header map[string]string) ([]byte, error)

func Request

func Request(url, method string, param map[string]string, header map[string]string) ([]byte, error)

Types

type Method

type Method string

type Option

type Option func(opt *Service)

func WithAddress

func WithAddress(host string, port int) Option

func WithCertificate

func WithCertificate(cert, key string) Option

func WithMaxBodySize

func WithMaxBodySize(size int) Option

func WithRate

func WithRate(sec, capacity int) Option

type Service

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

func New

func New(opts ...Option) *Service

func (*Service) Register

func (h *Service) Register(path, method string, f fasthttp.RequestHandler)

func (*Service) RegisterWS

func (h *Service) RegisterWS(path string, msgType int, cb WSCallback)

func (*Service) Run

func (h *Service) Run() error

Run 启动函数

type WS

type WS struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

type WSCallback

type WSCallback interface {
	OnConnect(ctx *fasthttp.RequestCtx, client *WSClient) error
	OnMessage(cli *WSClient, msgType int, msg []byte)
	OnClose(client *WSClient)
}

type WSClient

type WSClient struct {
	sync.RWMutex
	ConnId   int64
	UserData interface{}
	// contains filtered or unexported fields
}

func (*WSClient) LoopWrite

func (w *WSClient) LoopWrite()

func (*WSClient) Send

func (w *WSClient) Send(msg []byte)

Jump to

Keyboard shortcuts

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