Skip to content

Commit

Permalink
log username on invalid request
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkr committed Oct 2, 2024
1 parent 6cc35da commit 34c6845
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion front/gemini/gemini.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (gl *Listener) Handle(ctx context.Context, conn net.Conn) {
if r.User == nil {
r.Log = slog.With(slog.Group("request", "path", r.URL.Path))
} else {
r.Log = slog.With(slog.Group("request", "path", r.URL.Path, "user", r.User.ID))
r.Log = slog.With(slog.Group("request", "path", r.URL.Path, "user", r.User.PreferredUsername))
}

gl.Handler.Handle(&r, w)
Expand Down
3 changes: 1 addition & 2 deletions front/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/dimkr/tootik/cfg"
"github.com/dimkr/tootik/front/static"
"github.com/dimkr/tootik/front/text"
"log/slog"
"regexp"
"sync"
"time"
Expand Down Expand Up @@ -165,7 +164,7 @@ func (h *Handler) Handle(r *Request, w text.Writer) {
}
}

slog.Warn("Received an invalid request", "path", r.URL.Path)
r.Log.Warn("Received an invalid request")

if r.User == nil {
w.Redirect("/oops")
Expand Down

0 comments on commit 34c6845

Please sign in to comment.