Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New handler to skip access logs based on request matcher #4689

Closed
francislavoie opened this issue Apr 8, 2022 · 0 comments · Fixed by #4691
Closed

New handler to skip access logs based on request matcher #4689

francislavoie opened this issue Apr 8, 2022 · 0 comments · Fixed by #4691
Labels
feature ⚙️ New feature or request
Milestone

Comments

@francislavoie
Copy link
Member

There's demand for a way to skip certain access logs from being emitted based on request path: https://caddy.community/t/exclude-certain-requests-from-logs-based-on-request-path/15607

I think we can implement this by introducing a new HTTP handler skip_log (name TBD) which embeds a request matcher (not the matcher sibling to the route, but a matcher inside the handler, since we need the handler to get the match result back); when invoked, it would run the matcher and if the matcher returns true, then it would set a flag in the request's context (maybe in Vars, probably least invasive place to do it). Then later in server.go, in the defer func() that writes the access log, we can check for this skip flag to short circuit and skip emitting the log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature ⚙️ New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant