Our great sponsors
-
sandwich
Sandwich is a delicious middleware framework for go that lets you write and test your handlers easily. (by augustoroman)
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
https://github.com/augustoroman/sandwich is another approach for achieving a similar result. One nice aspect of writing handlers that return errors is that they are easy to test and clean to write.
Sandwich does very simple sequencing to achieve an understandable dependency injection mechanism that produces clear errors when something goes wrong, and it produces errors at setup time rather than run time.
In general, the way you output errors to the client and the errors you log are two totally different things. This is a slight tweak from the problem the author is attempting to solve by letting the client see the error.
Like the author, I created a special error interface I can look for when returning client errors: https://github.com/Xeoncross/public-error-go
The article basically describes how Caddy does error handling in HTTP routes.
https://github.com/caddyserver/caddy/blob/cb86319bd50322d4ac...
Goland collapses this to a single line, and vscode is looking into it too.
https://github.com/golang/vscode-go/issues/2311
It papers over the issue, but helps some.
Related posts
- How to securely reverse-proxy ASP.NET Core web apps
- οΈππ Top 3 DevOps Trends to Watch Out for in 2024 π
- οΈππ 3 Must Know Tools for Top DevOps Engineers π·
- οΈπ¨βπ§ 3 Tiny Fixes You Can Make To Start Contributing to Any Open Source Project π
- π₯ The Single Best Tip To Attract More Contributors To Your GitHub Projectπ‘