idecnode/pkg/apiv1/api.go

44 lines
1,011 B
Go

package apiv1
import (
"github.com/labstack/echo/v4"
"gitrepo.ru/neonxp/idecnode/pkg/config"
"gitrepo.ru/neonxp/idecnode/pkg/idec"
)
type API struct {
config *config.Config
idec *idec.IDEC
}
func New(i *idec.IDEC, cfg *config.Config) *API {
return &API{
config: cfg,
idec: i,
}
}
func (a *API) Register(e *echo.Echo) {
e.GET(`/list.txt`, a.getListHandler)
e.GET(`/blacklist.txt`, a.getBlacklistHandler)
func(g *echo.Group) {
g.GET(`/e/*`, a.getEchosHandler)
g.GET(`/m/*`, a.getBundleHandler)
g.GET(`/point/:pauth/:tmsg`, a.postPointHandler)
g.POST(`/point`, a.postPointHandler)
}(e.Group("/u"))
e.GET(`/e/:id`, a.getEchoHandler)
e.GET(`/m/:msgID`, a.getMessageHandler)
func(g *echo.Group) {
e.GET(`/features`, a.getFeaturesHandler)
e.GET(`/c/*`, a.getEchosInfo)
// e.POST(`/filelist`, a.getFilelistHandler)
// e.GET(`/filelist/:pauth`, a.getFilelistHandler)
// e.POST(`/file`, a.getFileHandler)
// e.GET(`/file/:filename`, a.getFileHandler)
}(e.Group("/x"))
}