22 lines
417 B
Go
22 lines
417 B
Go
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
|
|
}
|