Browse Source

增加sse推送

master
xyiege 7 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事件 // 处理sse事件
func handleEvents(w http.ResponseWriter, r *http.Request) { func SseHandler(w http.ResponseWriter, r *http.Request) {
// 设置 CORS 头部 // 设置 CORS 头部
//w.Header().Set("Access-Control-Allow-Origin", "*") //w.Header().Set("Access-Control-Allow-Origin", "*")
//w.Header().Set("Access-Control-Allow-Methods", "GET") //w.Header().Set("Access-Control-Allow-Methods", "GET")

7
aufs/main.go

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

Loading…
Cancel
Save