26 lines
431 B
Go
26 lines
431 B
Go
package quote
|
|
|
|
import (
|
|
"github.com/labstack/echo/v4"
|
|
"github.com/uptrace/bun"
|
|
)
|
|
|
|
type Handler struct {
|
|
db *bun.DB
|
|
}
|
|
|
|
// NewHandler returns new Handler.
|
|
func NewHandler(db *bun.DB) *Handler {
|
|
return &Handler{db: db}
|
|
}
|
|
|
|
func (h *Handler) Register(g *echo.Group) {
|
|
g.GET("", h.Index)
|
|
g.GET("quote/:id", h.Quote)
|
|
g.GET("random", h.Random)
|
|
g.GET("top", h.Top)
|
|
}
|
|
|
|
type Pagination struct {
|
|
Page int `query:"page" default:"0"`
|
|
}
|