diff options
author | GrailFinder <wohilas@gmail.com> | 2024-03-17 13:13:01 +0300 |
---|---|---|
committer | GrailFinder <wohilas@gmail.com> | 2024-03-17 13:13:01 +0300 |
commit | 33db3abdadd6687eb16305014c70654e03168fe5 (patch) | |
tree | 62b8f8766b896227fdc9ce15c0cac8530ced3099 /internal/handlers/main.go |
init
Diffstat (limited to 'internal/handlers/main.go')
-rw-r--r-- | internal/handlers/main.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/internal/handlers/main.go b/internal/handlers/main.go new file mode 100644 index 0000000..3b551f1 --- /dev/null +++ b/internal/handlers/main.go @@ -0,0 +1,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")) +} |