- 公网反代:Nginx 状态卡片(版本 / 运行状态 / 配置校验 / 端口监听) - 部署设置第一、二梯队(HTTPS 开关、安全头、限流、连接数、仅中国大陆 IP) - 隧道检测兼容 frps v0.68 / v0.71(V2 与旧版端点) - 恢复被清空的 internal/frp/store.go、internal/api/ddns_handler.go、web/src/views/DdnsView.vue
34 lines
828 B
Go
34 lines
828 B
Go
package api
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"github.com/fonu/fonu/internal/notify"
|
|
)
|
|
|
|
type NotifyHandler struct {
|
|
notify *notify.Service
|
|
}
|
|
|
|
func NewNotifyHandler(notifySvc *notify.Service) *NotifyHandler {
|
|
return &NotifyHandler{notify: notifySvc}
|
|
}
|
|
|
|
func (h *NotifyHandler) Test(w http.ResponseWriter, r *http.Request) {
|
|
if h.notify == nil {
|
|
writeError(r, w, http.StatusInternalServerError, "通知服务未初始化")
|
|
return
|
|
}
|
|
var req notify.TestInput
|
|
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
|
writeError(r, w, http.StatusBadRequest, "请求格式无效")
|
|
return
|
|
}
|
|
if err := h.notify.SendTest(r.Context(), req); err != nil {
|
|
writeError(r, w, http.StatusBadRequest, err.Error(), err)
|
|
return
|
|
}
|
|
writeJSON(w, http.StatusOK, map[string]string{"message": "测试通知已发送"})
|
|
}
|