Skip to content

Formatter responsibility should only be to format the error, not to handle the request #18

@ilariopro

Description

@ilariopro

Hi, I think this library is great, but why the formatters are responsible to return the final response?

I don't understand this design choice, mainly for these reasons:

  1. I consider this a violation of SRP: the formatter should only be responsible for formatting the error and returning it to the ErrorHandler. It should not depend on the ResponseFactory and StreamFactory.
  2. Currently, each FormatterInterface implementation depends on ResponseFactory and StreamFactory. This is acceptable when using the Factory helper, but it makes the dev experience difficult if you need to specify custom implementations.
  3. Potentially you can specify a different ResponseFactory/StreamFactory implementation for each formatter.

I could prepare a PR for this change, if you want. But it would be potentially a breaking change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions