2020-10-31 06:16:21 +13:00
|
|
|
package member
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/go-chi/chi"
|
|
|
|
|
|
|
|
"demodesk/neko/internal/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
type MemberHandler struct {
|
|
|
|
sessions types.SessionManager
|
|
|
|
websocket types.WebSocketHandler
|
|
|
|
}
|
|
|
|
|
|
|
|
func New(
|
|
|
|
sessions types.SessionManager,
|
|
|
|
websocket types.WebSocketHandler,
|
|
|
|
) *MemberHandler {
|
|
|
|
// Init
|
|
|
|
|
|
|
|
return &MemberHandler{
|
|
|
|
sessions: sessions,
|
|
|
|
websocket: websocket,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-31 22:48:24 +13:00
|
|
|
func (h *MemberHandler) Router(
|
|
|
|
usersOnly func(chi.Router, func(chi.Router)),
|
|
|
|
adminsOnly func(chi.Router, func(chi.Router)),
|
|
|
|
) *chi.Mux {
|
2020-10-31 06:16:21 +13:00
|
|
|
r := chi.NewRouter()
|
|
|
|
|
2020-10-31 22:48:24 +13:00
|
|
|
usersOnly(r, func(r chi.Router) {
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
adminsOnly(r, func(r chi.Router) {
|
|
|
|
|
|
|
|
})
|
2020-10-31 06:16:21 +13:00
|
|
|
|
|
|
|
return r
|
|
|
|
}
|