From b23fbd1d8e81fb110c98d878ee1a944217c497f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=BE=D0=B1=D0=B5=D0=BB=D0=B5=D0=B2=20=D0=90=D0=BD?= =?UTF-8?q?=D0=B4=D1=80=D0=B5=D0=B9=20=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B5?= =?UTF-8?q?=D0=B2=D0=B8=D1=87?= Date: Wed, 8 Jun 2022 10:30:13 +0300 Subject: [PATCH] remove http handlers --- map.go | 55 ------------------------------------------------------- 1 file changed, 55 deletions(-) diff --git a/map.go b/map.go index ab704e1..ed4a6f0 100644 --- a/map.go +++ b/map.go @@ -1,12 +1,8 @@ package bot import ( - "strconv" - "git.belvedersky.ru/common/logger/service" - "github.com/gofiber/fiber/v2" "github.com/puzpuzpuz/xsync" - "gopkg.in/telebot.v3" ) type Bots struct { @@ -20,54 +16,3 @@ func NewMap(Log *service.LoggerService) *Bots { I: xsync.NewMapOf[*Bot](), } } - -// Get godoc -// @Summary Получение бота -// @Description Получение бота по username -// @ID bots/get -// @Tags Боты -// @Param name path string true "Username бота" -// @Router /bot/{name} [get] -// @Success 200 {object} telebot.User -func (b *Bots) Get(c *fiber.Ctx) error { - name := c.Params("name") - if name != "" { - b.log.Log.Println("Запрос на получение бота", name) - _b, ok := b.I.Load(name) - if !ok { - botId, err := strconv.Atoi(name) - if err != nil { - return err - } - b.I.Range(func(key string, bot *Bot) bool { - if bot.Self().ID == int64(botId) { - _b = bot - return false - } - return true - }) - if _b == nil { - return c.Status(404).SendString("not found") - } - } - return c.JSON(_b.Self()) - } - return c.Status(404).SendString("not found") -} - -// List godoc -// @Summary Получение списка ботов -// @Description Получение списка ботов -// @ID bots/list -// @Tags Боты -// @Router /bot/list [get] -// @Success 200 {array} telebot.User -func (b *Bots) List(c *fiber.Ctx) error { - bots := []*telebot.User{} - b.I.Range(func(key string, value *Bot) bool { - bot := value - bots = append(bots, bot.Self()) - return true - }) - return c.JSON(bots) -}