shorgru/pkg/handler/quote/quote.go

28 lines
495 B
Go
Raw Permalink Normal View History

package quote
2024-10-06 17:04:37 +03:00
import (
"strconv"
"github.com/labstack/echo/v4"
"sh.org.ru/pkg/model"
"sh.org.ru/pkg/tpl"
)
func (h *Handler) Quote(c echo.Context) error {
sid := c.Param("id")
id, err := strconv.Atoi(sid)
if err != nil {
return echo.ErrNotFound
2024-10-06 17:04:37 +03:00
}
quote := new(model.Quote)
err = h.db.NewSelect().
2024-10-06 17:04:37 +03:00
Model(quote).
Where("id = ?", id).Scan(c.Request().Context(), quote)
if err != nil {
return err
}
return tpl.QuotePage(quote).Render(c.Request().Context(), c.Response())
}