go-chi / go-chi/chi

[Proposal] Custom parser in recover middleware

Open
#796 4 comments 3 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
22.8k
Forks
1.2k
Avg merge
5h 17m
Merged PRs (30d)
10

Description

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: https://github.com/PumpkinSeed/chi-recover-proposal/pull/1

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.