Skip to content

souin middleware doesn't support best practice for error handling in caddy cache handler #642

@yuvalman

Description

@yuvalman

Hi,
After consulting with Caddy community about error handling best practices, the souin middleware used by https://github.com/caddyserver/cache-handler, can follow the best practices?
Here is the community discussion: https://caddy.community/t/best-practices-for-handling-errors-in-chain-of-custom-modules/31101

In this code: https://github.com/darkweak/souin/blob/master/pkg/middleware/middleware.go#L976-L981

we can see the middleware write bytes and not return nil or HandlerError, which does not follow the best practices (which means the chain will continue to the next middleware, and it's body response ("Internal server error" string) will be flushed to the next middlewares in the chain, which can cause unexpected behavior).

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