66 "net/http"
77 "time"
88
9- "github.com/labstack/echo/v4 "
9+ "github.com/labstack/echo/v5 "
1010
1111 "github.com/usememos/memos/server/auth"
1212 "github.com/usememos/memos/store"
@@ -20,15 +20,15 @@ const (
2020// RegisterSSERoutes registers the SSE endpoint on the given Echo instance.
2121func RegisterSSERoutes (echoServer * echo.Echo , hub * SSEHub , storeInstance * store.Store , secret string ) {
2222 authenticator := auth .NewAuthenticator (storeInstance , secret )
23- echoServer .GET ("/api/v1/sse" , func (c echo.Context ) error {
23+ echoServer .GET ("/api/v1/sse" , func (c * echo.Context ) error {
2424 return handleSSE (c , hub , authenticator )
2525 })
2626}
2727
2828// handleSSE handles the SSE connection for live memo refresh.
2929// Authentication is done via Bearer token in the Authorization header,
3030// or via the "token" query parameter (for EventSource which cannot set headers).
31- func handleSSE (c echo.Context , hub * SSEHub , authenticator * auth.Authenticator ) error {
31+ func handleSSE (c * echo.Context , hub * SSEHub , authenticator * auth.Authenticator ) error {
3232 // Authenticate the request.
3333 authHeader := c .Request ().Header .Get ("Authorization" )
3434 if authHeader == "" {
@@ -52,7 +52,7 @@ func handleSSE(c echo.Context, hub *SSEHub, authenticator *auth.Authenticator) e
5252 w .WriteHeader (http .StatusOK )
5353
5454 // Flush headers immediately.
55- if f , ok := w .Writer . (http.Flusher ); ok {
55+ if f , ok := w .(http.Flusher ); ok {
5656 f .Flush ()
5757 }
5858
@@ -84,7 +84,7 @@ func handleSSE(c echo.Context, hub *SSEHub, authenticator *auth.Authenticator) e
8484 if _ , err := fmt .Fprintf (w , "data: %s\n \n " , data ); err != nil {
8585 return nil
8686 }
87- if f , ok := w .Writer . (http.Flusher ); ok {
87+ if f , ok := w .(http.Flusher ); ok {
8888 f .Flush ()
8989 }
9090
@@ -93,7 +93,7 @@ func handleSSE(c echo.Context, hub *SSEHub, authenticator *auth.Authenticator) e
9393 if _ , err := fmt .Fprint (w , ": heartbeat\n \n " ); err != nil {
9494 return nil
9595 }
96- if f , ok := w .Writer . (http.Flusher ); ok {
96+ if f , ok := w .(http.Flusher ); ok {
9797 f .Flush ()
9898 }
9999 }
0 commit comments