gin
gin copied to clipboard
Pretty HTML output for build errors / runtime panics
Hi,
Did you plan to add some nice looking HTML output to gin for errors/panics in proxy.go, instead of just the raw string? Maybe something similar looking to revel could be done: http://robfig.github.io/revel/img/Panic.png ?
For just build errors the error message parsing to get the filename and linenumber should be pretty simple. Not sure about panics though.
If you don't have anything like this already planned, I could give it a try if you'd like?
Yeah that was the original plan.
We could handle panics by modifying the Panic middleware in martini to give us all the info and send a X-Martini-Panic
header in the response. This obviously would only occur in development mode. The proxy can then catch that and display it in a nicer way. Kinda hacky but also doesn't tie Martini to Gin.
Thoughts?
Hmm yeah, sounds like a good idea. My plan would have been to constantly watch and look for patterns of a panic message in the stdout/stderr of the app gin is proxying. But just having to look for a specific header is much simpler.
..I just looked at the recovery middleware again and had an idea. Since we're gonna modify it anyway to provide more information in case of a panic, why not just have it also return a pretty HTML panic message while in development mode, instead of just the 500 status code as it does currently? This obviously only works if the panic occurs before martini already sent a response, but the same would be true for the special header anyway.
I went ahead and tried it out, it works quite well actually. Check out the PR I made: https://github.com/codegangsta/martini/pull/156 :)
This way it will keep gin and martini not dependant on each other and gin only takes care of build errors. It can front and proxy to any similar go web framework.
Yeah, thats what I love about gin, it is not martini-specific. Any web app that can take PORT as an environment variable (and really why shouldn't you do that?) will work with gin