response

package
v1.3.23 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NoResponse

func NoResponse(_ *mqtt_client.MqttClient, _ *router.Item, _ Identifier, _ any, _ error)

func SendIDResponse

func SendIDResponse[T IDType](c *mqtt_client.MqttClient, item *router.Item, responseIdentifier Identifier, id T, err error)

func SendInfoResponse

func SendInfoResponse[T any](c *mqtt_client.MqttClient, item *router.Item, responseIdentifier Identifier, info T, err error)

func SendInfosResponse

func SendInfosResponse[T any](c *mqtt_client.MqttClient, item *router.Item, responseIdentifier Identifier, data InfosData[T], err error)

func SendMapResponse

func SendMapResponse(c *mqtt_client.MqttClient, item *router.Item, responseIdentifier Identifier, data map[string]any, err error)

func SendMsgResponse

func SendMsgResponse(c *mqtt_client.MqttClient, item *router.Item, responseIdentifier Identifier, _ any, err error)

func SendString

func SendString(c *mqtt_client.MqttClient, item *router.Item, responseIdentifier Identifier, data string, err error)

func StructToMap

func StructToMap(originStruct any) map[string]any

func WriteBytes

func WriteBytes(c *mqtt_client.MqttClient, item *router.Item, responseIdentifier Identifier, bytes []byte, err error)

Types

type IDResponse

type IDResponse[T IDType] struct {
	MsgResponse
	ID T `json:"id"`
}

type IDType

type IDType interface {
	~string | ~uint64
}

type Identifier added in v1.3.9

type Identifier interface {
	Identifier() string
	Copy() Identifier
}

type InfoResponse

type InfoResponse[T any] struct {
	MsgResponse
	Info T `json:"info"`
}

type InfosData

type InfosData[T any] struct {
	Infos      []T   `json:"infos"`
	TotalCount int64 `json:"totalCount"`
	PageNo     int   `json:"pageNo"`
}

type InfosResponse

type InfosResponse[T any] struct {
	MsgResponse
	InfosData[T]
}

type MsgResponse

type MsgResponse struct {
	Success bool   `json:"success"`
	ErrCode int    `json:"errCode"`
	Msg     string `json:"msg"`
}

type SendFunc

type SendFunc[T any] func(c *mqtt_client.MqttClient, item *router.Item, identifier Identifier, data T, err error)

Jump to

Keyboard shortcuts

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