server

package
v0.0.0-...-99ebd93 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: GPL-3.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaximumImageSize        = 10 * 1024 * 1024
	AllowedUploadsPerMinute = 100
	RequestInterval         = time.Minute
)

Variables

This section is empty.

Functions

func CreateHandleValidation

func CreateHandleValidation(botSecret string, wh *WebhookHandler) gin.HandlerFunc

CreateHandleValidation 创建用于签名验证和消息入队的处理函数

func GetIDHandler

func GetIDHandler(c *gin.Context)

func HandleIpupdate

func HandleIpupdate(c *gin.Context)

func UploadBase64ImageHandler

func UploadBase64ImageHandler(rateLimiter *RateLimiter) gin.HandlerFunc

闭包,网页后端,图床逻辑,基于gin和www静态文件的简易图床

func UploadBase64ImageHandlerV2

func UploadBase64ImageHandlerV2(rateLimiter *RateLimiter, apiv2 openapi.OpenAPI) gin.HandlerFunc

func UploadBase64ImageHandlerV3

func UploadBase64ImageHandlerV3(rateLimiter *RateLimiter, apiv1 openapi.OpenAPI) gin.HandlerFunc

func UploadBase64RecordHandler

func UploadBase64RecordHandler(rateLimiter *RateLimiter) gin.HandlerFunc

闭包,网页后端,语音床逻辑,基于gin和www静态文件的简易语音床

func WsHandlerWithDependencies

func WsHandlerWithDependencies(api openapi.OpenAPI, apiV2 openapi.OpenAPI, p *Processor.Processors) gin.HandlerFunc

使用闭包结构 因为gin需要c *gin.Context固定签名

Types

type Payload

type Payload struct {
	D  ValidationRequest `json:"d"`
	Op int               `json:"op"`
}

Payload 定义请求载荷结构

type RateLimiter

type RateLimiter struct {
	Counts map[string][]time.Time
}

func NewRateLimiter

func NewRateLimiter() *RateLimiter

频率限制器

func (*RateLimiter) CheckAndUpdateRateLimit

func (rl *RateLimiter) CheckAndUpdateRateLimit(ipAddress string) bool

检查是否超过调用频率限制

type ValidationRequest

type ValidationRequest struct {
	PlainToken string `json:"plain_token"`
	EventTs    string `json:"event_ts"`
}

ValidationRequest 定义鉴权请求结构

type WebSocketServerClient

type WebSocketServerClient struct {
	Conn  *websocket.Conn
	API   openapi.OpenAPI
	APIv2 openapi.OpenAPI
	// contains filtered or unexported fields
}

func (*WebSocketServerClient) Close

func (client *WebSocketServerClient) Close() error

func (*WebSocketServerClient) SendMessage

func (c *WebSocketServerClient) SendMessage(message map[string]interface{}) error

发信息给client

type WebhookHandler

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

WebhookHandler 负责处理 Webhook 的接收和消息处理

func NewWebhookHandler

func NewWebhookHandler(queueSize int) *WebhookHandler

NewWebhookHandler 创建新的 WebhookHandler 实例

func (*WebhookHandler) Close

func (wh *WebhookHandler) Close()

Close 关闭消息队列

func (*WebhookHandler) ListenAndProcessMessages

func (wh *WebhookHandler) ListenAndProcessMessages()

listenAndProcessMessages 启动协程处理队列中的消息

type WebhookPayload

type WebhookPayload struct {
	PlainToken string `json:"plain_token"`
	EventTs    string `json:"event_ts"`
	RawMessage []byte // 保存原始消息内容
}

WebhookPayload 定义Webhook消息结构

Jump to

Keyboard shortcuts

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