Re:Go: Ten years and climbing
by agnivade on Friday September 22, 2017 @01:51AM
(#15309699)
> What is the best way to map objects to/from JSON? - What is the best way to map objects to/from a database?
If you are doing heavy sql queries, then it might be beneficial for you to use an ORM. There are plently of those out there, so choose one you like. Just create structs for your tables and run your queries.
If you are doing light/moderate sql. Just have an interface for your db calls, wrap your responses in a struct and use json tags for json encoding/decoding.
> What is the best way to prevent a request from crashing the server and killing a bunch of unrelated requests?
I use negroni. And its recovery middleware does exactly that.
If you are doing heavy sql queries, then it might be beneficial for you to use an ORM. There are plently of those out there, so choose one you like. Just create structs for your tables and run your queries.
If you are doing light/moderate sql. Just have an interface for your db calls, wrap your responses in a struct and use json tags for json encoding/decoding.
> What is the best way to prevent a request from crashing the server and killing a bunch of unrelated requests?
I use negroni. And its recovery middleware does exactly that.