feat: 基本的websocket echo服务
This commit is contained in:
@ -1,16 +1,19 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"git.jinshen.cn/remilia/push-server/interval/api/handler"
|
||||
"git.jinshen.cn/remilia/push-server/interval/hub"
|
||||
"git.jinshen.cn/remilia/push-server/interval/ws"
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
func NewRouter(h *hub.Hub) http.Handler {
|
||||
func NewRouter(h *ws.Hub, ctx context.Context) http.Handler {
|
||||
r := chi.NewRouter()
|
||||
|
||||
r.Get("/ws", ws.Handler(ctx, h))
|
||||
|
||||
r.Post("/health", handler.Health)
|
||||
r.Post("/push/{topic}", handler.PushHandler(h))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user