Skip to content

filters applied after request mutated, potential to waste resources #20

Description

@timruffles

The filter options look designed to allow you to have different configurations per endpoint. However, the filters are applied after the request/response recording is set up. Therefore:

slogchi.NewWithConfig(slog, slogchi.Config{
    WithRequestBody: true,
    Filters: []slogchi.Filter{ slogchi.AcceptPathPrefix("/foo") },
})
slogchi.NewWithConfig(slog, slogchi.Config{
    WithRequestBody: true,
    Filters: []slogchi.Filter{ slogchi.AcceptPathPrefix("/bar") },
})

will result in two copies of request body being buffered for every request, regardless of whether it matches the filters.

I see 9501154, but this is still applied after the request is mutated with new reader/writers. I think filters should be processed here before the r.Body code is run.

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