update project

This commit is contained in:
2024-11-25 16:10:58 +01:00
parent a6f3325842
commit 958ef12e91
9 changed files with 108 additions and 91 deletions
+12 -26
View File
@@ -1,44 +1,30 @@
package handlers
import (
"context"
"gopher-toolbox/app"
"log/slog"
"net/http"
"ron"
"gopher-toolbox/app"
"github.com/gofiber/fiber/v2"
"github.com/zepyrshut/rating-orama/internal/repository"
)
type Handlers struct {
App *app.App
Queries repository.ExtendedQuerier
app *app.App
queries repository.ExtendedQuerier
}
func New(q repository.ExtendedQuerier, app *app.App) *Handlers {
func New(app *app.App, q repository.ExtendedQuerier) *Handlers {
return &Handlers{
Queries: q,
App: app,
app: app,
queries: q,
}
}
func (hq *Handlers) ToBeImplemented(c *ron.CTX, ctx context.Context) {
c.JSON(http.StatusOK, ron.Data{
"message": "Not implemented yet",
})
func (hq *Handlers) ToBeImplemented(c *fiber.Ctx) error {
return c.Status(http.StatusNotImplemented).JSON("not implemented")
}
func (hq *Handlers) Ping(c *ron.CTX, ctx context.Context) {
slog.Info("ping", ron.RequestID, ctx.Value(ron.RequestID))
c.JSON(http.StatusOK, ron.Data{
"message": "pong",
})
}
func (hq *Handlers) Error(c *ron.CTX, ctx context.Context) {
slog.Error("error", ron.RequestID, ctx.Value(ron.RequestID))
c.JSON(http.StatusInternalServerError, ron.Data{
"req": ctx.Value(ron.RequestID),
"message": "error",
})
func (hq *Handlers) Ping(c *fiber.Ctx) error {
return c.JSON("pong")
}