56 lines
1.1 KiB
Go
56 lines
1.1 KiB
Go
package handlers
|
|
|
|
import (
|
|
"log/slog"
|
|
"ron"
|
|
"ron-pets/internal/config"
|
|
)
|
|
|
|
type Handlers struct {
|
|
app *config.App
|
|
}
|
|
|
|
func New(app *config.App) *Handlers {
|
|
return &Handlers{
|
|
app: app,
|
|
}
|
|
}
|
|
|
|
func (hq *Handlers) HelloWorld(c *ron.Context) {
|
|
slog.Info("Dummy info message")
|
|
c.W.Write([]byte("hello world"))
|
|
}
|
|
|
|
func (hq *Handlers) AnotherHelloWorld(c *ron.Context) {
|
|
c.W.Write([]byte("another hello world"))
|
|
}
|
|
|
|
func (hq *Handlers) HelloWorldJSON(c *ron.Context) {
|
|
id := c.R.PathValue("id")
|
|
slog.Info("path value", "id", id)
|
|
|
|
c.JSON(200, ron.Data{"message": "hello world"})
|
|
}
|
|
|
|
func (hq *Handlers) HelloWorldHTML(c *ron.Context) {
|
|
|
|
//pages := ron.Pages{
|
|
// TotalElements: len(elements),
|
|
// ElementsPerPage: 5,
|
|
//}
|
|
//
|
|
//pages.PaginationParams(c.R)
|
|
//elementsPaginated := pages.PaginateArray(elements)
|
|
//
|
|
//td := &ron.TemplateData{
|
|
// Data: ron.Data{"title": "hello world", "message": "hello world from html", "elements": elementsPaginated},
|
|
// Pages: pages,
|
|
//}
|
|
//
|
|
//c.HTML(200, "page.index.gohtml", td)
|
|
}
|
|
|
|
func (hq *Handlers) ComponentHTML(c *ron.Context) {
|
|
c.HTML(200, "component.list.gohtml", nil)
|
|
}
|