Skip to content

refactor: routing info middleware#37653

Merged
wxiaoguang merged 2 commits into
go-gitea:mainfrom
wxiaoguang:fix-request-info
May 11, 2026
Merged

refactor: routing info middleware#37653
wxiaoguang merged 2 commits into
go-gitea:mainfrom
wxiaoguang:fix-request-info

Conversation

@wxiaoguang
Copy link
Copy Markdown
Contributor

fix #37650

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 11, 2026
@wxiaoguang wxiaoguang requested a review from Copilot May 11, 2026 12:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes #37650 by ensuring routing request metadata (used by helpers like routing.MarkLongPolling) is always present in the request context, even when the router logger is disabled, preventing nil-pointer panics in dev mode (e.g. Vite dev proxy).

Changes:

  • Replace conditional routing.NewLoggerHandler() registration with an always-on routing.NewRequestInfoHandler() middleware.
  • Refactor routing logger internals to decouple “request info in context” from “router logging + slow query detection”.
  • Rename/reshape requestRecord fields to align with the refactor (responseWriterrespWriter, mutable fields grouped).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
routers/common/middleware.go Always installs request-info middleware so request records exist even when router logging is disabled.
modules/web/routing/requestrecord.go Restructures requestRecord fields and renames writer field.
modules/web/routing/requestinfo.go New middleware that always injects request record; optionally enables router logging/slow query detection.
modules/web/routing/logger.go Updates logger to use renamed respWriter field.
modules/web/routing/logger_manager.go Refactors request-record manager logic to work with the new request-info middleware.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread routers/common/middleware.go
Comment thread modules/web/routing/requestinfo.go Outdated
Comment thread modules/web/routing/requestinfo.go Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Comment thread modules/web/routing/logger_manager.go Outdated
Comment thread modules/web/routing/requestinfo.go
Comment thread modules/web/routing/requestinfo.go Outdated
@wxiaoguang wxiaoguang added the skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. label May 11, 2026
Copy link
Copy Markdown
Member

@bircni bircni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you! works now

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 11, 2026
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels May 11, 2026
@wxiaoguang wxiaoguang merged commit 2eb7b3c into go-gitea:main May 11, 2026
21 checks passed
@GiteaBot GiteaBot added this to the 1.27.0 milestone May 11, 2026
@wxiaoguang wxiaoguang deleted the fix-request-info branch May 11, 2026 14:39
zjjhot added a commit to zjjhot/gitea that referenced this pull request May 12, 2026
* main:
  fix(deps): update dependency mermaid to v11.15.0 [security], add e2e test (go-gitea#37662)
  ci: Also lint json5 files (go-gitea#37659)
  fix(templates): avoid misleading compare message when branches lack merge base (go-gitea#37651)
  fix(deps): update npm dependencies (go-gitea#37647)
  refactor: routing info middleware (go-gitea#37653)
  chore(deps): update action dependencies (major) (go-gitea#37638)
  fix(deps): update go dependencies (major) (go-gitea#37639)
  ci(renovate): update Go import paths on major bumps (go-gitea#37641)
  fix(packages): Add label for private and internal package and fix composor package source permission check (go-gitea#37610)
  refactor: replace Fomantic search module with first-party code (go-gitea#37443)
  fix(deps): update npm dependencies (go-gitea#37636)
  fix(deps): update module code.gitea.io/sdk/gitea to v0.25.0 (go-gitea#37637)
  feat(api): add last_sync to repository API (go-gitea#37566)
  test(e2e): run playwright via container (go-gitea#37300)
  feat(editor): broaden language detection in web code editor (go-gitea#37619)
  refactor(log): replace log.Critical with log.Error (go-gitea#37624)
  fix: "run as root" check (go-gitea#37622)
  fix: improve actions status icons and texts (go-gitea#37206)

# Conflicts:
#	pnpm-workspace.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic in routing.MarkLongPolling when logger.router is disabled in dev mode

5 participants