pebble-dev / rebblestore-api

Rebble Store api code.
MIT License
39 stars 8 forks source link

Restructure the HTTP handlers #14

Closed phpeter closed 7 years ago

phpeter commented 7 years ago

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.

sGerli commented 7 years ago

@azertyfun , what do you think about this, is it compatible with your DB work?

azertyfun commented 7 years ago

It should be. I might have to manually merge a file or two, but otherwise it looks great.