Skip to content

Include bytes read in hlog.AccessHandler middleware #561

Open
@dillonstreator

Description

@dillonstreator

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 {}
//...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions