refactor: 重构项目结构
- 将server端相关依赖单独防止在server中
This commit is contained in:
21
interval/server/api/router.go
Normal file
21
interval/server/api/router.go
Normal file
@ -0,0 +1,21 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"git.jinshen.cn/remilia/push-server/interval/server/api/handler"
|
||||
"git.jinshen.cn/remilia/push-server/interval/server/ws"
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
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))
|
||||
|
||||
return r
|
||||
}
|
||||
Reference in New Issue
Block a user