blob: 3b551f1af8846c58e606e92a3adda6c6e7c48d91 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
package handlers
import (
"log/slog"
"net/http"
"os"
"apjournal/config"
)
// Handlers structure
type Handlers struct {
cfg config.Config
// s *service.Service
log *slog.Logger
}
// NewHandlers constructor
func NewHandlers(
// cfg config.Config, s *service.Service, l *slog.Logger,
cfg config.Config, l *slog.Logger,
) *Handlers {
if l == nil {
l = slog.New(slog.NewJSONHandler(os.Stdout, nil))
}
h := &Handlers{
cfg: cfg,
// s: s,
log: l,
}
return h
}
func (h *Handlers) Ping(w http.ResponseWriter, r *http.Request) {
h.log.Info("got ping request")
w.Write([]byte("pong"))
}
|