AdaephonBen / cryptex

2 stars 0 forks source link

Leaderboard Route #11

Closed RachitKeertiDas closed 4 years ago

RachitKeertiDas commented 4 years ago

Add a Route for Leaderboard. Handle GET requests from the user to serve him the leaderboard in the form of JSON.

Also, the helper ServeJSON should simply return incase there is an error is encoding into JSON and should not write a malformed JSON.

AdaephonBen commented 4 years ago

Nice catch! Don't handle the error by just returning; log a warning using the appropriate function in package logs. Also, run the following command inside the server directory once you're done: gofmt -s -w . This will format all the code you've written.

RachitKeertiDas commented 4 years ago

Thanks for the gofmt tip! I have added the required changes. To log errors, I have imported the "log" package in helpers.go.

I have used the standard log package as this package has been used in handlers.go. However, the logs package has not been used anywhere in the routes directory.

npalladium commented 4 years ago

Notes:

References:

npalladium commented 4 years ago

I have used the standard log package as this package has been used in handlers.go. However, the logs package has not been used anywhere in the routes directory.

We'll probably get a proper logging package added soon.

npalladium commented 4 years ago

Closed the PR. Sorry. Send a fresh one. Two commits only please. I gave up on @AdaephonBen. Hoping I'll get good git practices from you, @RachitKeertiDas

RachitKeertiDas commented 4 years ago

Roger that.

I have used the standard log package as this package has been used in handlers.go. However, the logs package has not been used anywhere in the routes directory.

We'll probably get a proper logging package added soon.

Will switch to logrus and then re-send a PR