Browse Source

增加sse推送

master
xyiege 6 months ago
parent
commit
7aa45f9106
  1. 2
      aufs/core/sse.go
  2. 7
      aufs/main.go

2
aufs/core/sse.go

@ -8,7 +8,7 @@ import (
)
// 处理sse事件
func handleEvents(w http.ResponseWriter, r *http.Request) {
func SseHandler(w http.ResponseWriter, r *http.Request) {
// 设置 CORS 头部
//w.Header().Set("Access-Control-Allow-Origin", "*")
//w.Header().Set("Access-Control-Allow-Methods", "GET")

7
aufs/main.go

@ -2,6 +2,7 @@ package main
import (
"aufs/config"
"aufs/core"
"fmt"
"log"
"net/http"
@ -18,10 +19,12 @@ func startWeb() {
http.HandleFunc("/sc", core.SerInfo)
// 数据库基础信息
http.HandleFunc("/bs", core.BfsInfo)
// sse 推送
http.HandleFunc("/sse", core.SseHandler)
// 文件接收
http.HandleFunc("/rc", core.ReceiveHandler)
// http.HandleFunc("/rc", core.ReceiveHandler)
// 发送zip文件
http.HandleFunc("/sendZip", core.SendZip)
// http.HandleFunc("/sendZip", core.SendZip)
fmt.Printf("Starting server at port 9099\n")
// 启动HTTP服务器并监听端口 80,如果出现错误,则打印错误信息并退出

Loading…
Cancel
Save