These are chat archives for gin-gonic/gin

12th
Aug 2015
Chris
@ChristopherRabotin
Aug 12 2015 16:18
@olanod that's a good question that I'm asking myself too. What I do is make sure to separate the parts of my API which need to be blazing fast, and those which can be a bit slower or are more tied into other parts of the infrastructure. In my case, our API currently runs on Django (Python). It works great when we have to get a ton of stuff from the database or from other external sources. However, we also have two main endpoints which need to be blazing fast and whose return value is not used on the client side (unless an error code is returned). These are the ones we are porting to gin, mainly because we can make use of channels in go to deliver incredible speed on these endpoints.
So the first heads up is this: are you sure you should be porting all your app to gin?
To answer directly your question though, as per the Go documentation on project organization, you should only use subfolders if what is in there can be used as a separate package. So the best practice is to put all your .go files and associated tests in the same folder.
In https://github.com/ChristopherRabotin/gin-contrib-headerauth/tree/master/example/sha384, I demonstrate a very very basic example of putting a middleware definition in mgr.go but the router is defined in example.go .
I hope this helps!
Daniel Olano
@olanod
Aug 12 2015 16:25
thanks @ChristopherRabotin I'll have a look.
I'm doing this also to get more familiar with Go, the current Api works fine and I'm slowly porting it and when I see it's stable I'll probably replace it so there's no rush. It's also to prove the rest of the team that go is worth it ;)
Chris
@ChristopherRabotin
Aug 12 2015 16:30
I understand! I'm on a similar path right now ;)
How come Gin responds 404 instead of 406 if one tries to access an endpoint using an unsupported method?
Chris
@ChristopherRabotin
Aug 12 2015 19:10
Also, how can I return an empty response (bypassing the need for an IO reader)? I can return an empty string, but that's it.
Jamie Stackhouse
@itsjamie
Aug 12 2015 20:18
@olanod you can use AbortWithStatus to send a response code.
@ChristopherRabotin see above, sorry olanod, bad mobile user here.