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

Include bytes read in hlog.AccessHandler middleware #561

Open
dillonstreator opened this issue Jul 5, 2023 · 0 comments · May be fixed by #562
Open

Include bytes read in hlog.AccessHandler middleware #561

dillonstreator opened this issue Jul 5, 2023 · 0 comments · May be fixed by #562

Comments

@dillonstreator
Copy link

dillonstreator commented Jul 5, 2023

Currently, the hlog.AccessHandler middleware exposes the number of bytes written but does not surface the number of bytes read off of the request body.

As the introduction of a new field would break the AccessHandler API, I'd propose the creation of a new function that provides a struct to the callback function containing the number of read bytes as well as the existing datapoints. This will also enable future additions without breaking the interface.

package hlog
//...
type AccessHandlerNewData struct {
  BytesRead int64
  BytesWritten int
  Status int
  Duration time.Duration
  Request *http.Request
}

func AccessHandlerNew(fn func(AccessHandlerNewData)) func(next http.Handler) http.Handler {}
//...
@dillonstreator dillonstreator linked a pull request Jul 6, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant