Required request body is missing:xxxxxxxxxxxxx(com.alibaba.fastjson.JSONObject)

问题体现:

在这里插入图片描述

原因

接口内定义了@RequestBody JSONObject jsonObject,但是你用接口时,并没有按规定传参数。

解决

按照接口规范传参

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
好的,我可以帮你写一个简单的程序来实现这个功能。首先,你需要安装 Go 语言的开发环境。然后,按照以下步骤进行操作: 1. 导入必要的包: ```go package main import ( "crypto/tls" "fmt" "net/http" "time" ) ``` 2. 设置需要检查的域名和端口号: ```go const ( domain = "scf.tencentcloudapi.com" port = "443" ) ``` 3. 设置提醒阈值和钉钉机器人 Webhook: ```go const ( remindThreshold = 30 * 24 * time.Hour // 30 天 dingTalkWebhook = "https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxx" ) ``` 4. 编写一个函数来检查 SSL 证书是否过期: ```go func checkSSLExpiration() { // 构建 TLS 配置 tlsConfig := &tls.Config{ InsecureSkipVerify: true, // 跳过证书验证 } // 构建 HTTP 客户端 client := &http.Client{ Transport: &http.Transport{ TLSClientConfig: tlsConfig, }, Timeout: 10 * time.Second, } // 发送 HTTP 请求 url := fmt.Sprintf("https://%s:%s", domain, port) resp, err := client.Get(url) if err != nil { fmt.Println("Failed to get SSL certificate:", err) return } // 获取证书信息 certs := resp.TLS.PeerCertificates if len(certs) == 0 { fmt.Println("No SSL certificate found.") return } // 检查证书过期时间 expiration := certs[0].NotAfter daysLeft := expiration.Sub(time.Now()) if daysLeft < remindThreshold { // 发送钉钉提醒 message := fmt.Sprintf("SSL certificate for %s will expire in %d days.", domain, daysLeft/time.Hour/24) sendDingTalkMessage(message) } } ``` 5. 编写一个函数来发送钉钉提醒: ```go func sendDingTalkMessage(message string) { // 构建请求体 requestBody := fmt.Sprintf(`{ "msgtype": "text", "text": { "content": "%s" } }`, message) // 发送 HTTP POST 请求 client := &http.Client{Timeout: 10 * time.Second} resp, err := client.Post(dingTalkWebhook, "application/json", strings.NewReader(requestBody)) if err != nil { fmt.Println("Failed to send DingTalk message:", err) return } defer resp.Body.Close() // 解析响应 responseBytes, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println("Failed to read DingTalk response:", err) return } response := make(map[string]interface{}) json.Unmarshal(responseBytes, &response) if response["errcode"].(float64) != 0 { fmt.Println("Failed to send DingTalk message:", response["errmsg"].(string)) return } // 提醒发送成功 fmt.Println("DingTalk message sent successfully:", message) } ``` 6. 最后,在 `main` 函数中设置一个定时器来定期检查 SSL 证书: ```go func main() { ticker := time.NewTicker(24 * time.Hour) // 每 24 小时检查一次 for { select { case <-ticker.C: checkSSLExpiration() } } } ``` 这个程序会每 24 小时检查一次 SSL 证书的过期时间,并在证书过期时间少于 30 天时发送钉钉提醒。你需要将 `dingTalkWebhook` 替换为你自己的钉钉机器人 Webhook 地址。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值