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

[Proposal] Custom parser in recover middleware #796

Open
PumpkinSeed opened this issue Feb 18, 2023 · 4 comments
Open

[Proposal] Custom parser in recover middleware #796

PumpkinSeed opened this issue Feb 18, 2023 · 4 comments

Comments

@PumpkinSeed
Copy link

PumpkinSeed commented Feb 18, 2023

The parser of the recover middleware is hard coded. The only issue with this, that most of the log aggregator solutions can't handle that kind of format. As I checked the code prettyStack is the actual implementation of the parser inside the recover.go.

Proposal

What do you think about to create an interface with a method: Parse(debugStack []byte, rvr interface{}) ([]byte, error), and a singleton pattern like var stackParser {INTERFACENAME} = prettyStack{}. After we can use the stackParser in the PrintPrettyStack. Also adding a function to SetStackParser({INTERFACENAME}).

What do you think about? If you like it, I can implement it with a few tests.

The proposal looks like this: PumpkinSeed#1

@mfcochauxlaberge
Copy link

I think a better approach is to just let developers use their own recovering strategy.

@PumpkinSeed
Copy link
Author

How is this relevant to this proposal?

@mfcochauxlaberge
Copy link

My understanding is that you want to alter the logic of the Recoverer middleware, is that right?

Your proposal adds complexity to the current Recoverer middleware. I think a better approach is to simply use your own middleware.

Apologies if I misinterpreted your proposal.

@PumpkinSeed
Copy link
Author

Yes, you are right.

The main reason behind the proposal to have the same functionality as it was, but make it modular so if anyone wants to have an other format for the printed output they could have make it.

If everybody write their own middleware then what's the point of having open source code? I think people develop open-source projects to solve a common problem which suits as many people as possible. On the other hand there will be hundreds of the copies of the same code plus a few lines.

I agree if you are not accepting this proposal for certain reason, but I think this is the reason why people writing open-source code, because it can be altered to serve more people needs by being backward compatible.

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

No branches or pull requests

2 participants