I've added a context struct and a custom handler struct. The context only contains the DB now, but can also house user info, authentication, etc. The custom handler (via implementing the ServeHTTP function) allows us to check authentication and handle errors all in a single place.
Please let me know if you have any questions or if there's anything I need to change.
Inspired by this article.
I've added a context struct and a custom handler struct. The context only contains the DB now, but can also house user info, authentication, etc. The custom handler (via implementing the ServeHTTP function) allows us to check authentication and handle errors all in a single place.
Please let me know if you have any questions or if there's anything I need to change.