Proper way to handle api routes with Go

Hey, I'm just wondering what the correct way to handle API routes with Go is. Currently, I have a route, for example, /post, and then I am switching over the request method to handle it. So, if you send a GET request to /post, it retrieves all the posts. If you send a POST request to /post, it creates a new post. Is this the correct way, or is having a separate route for each method a better approach?
Solution:
either is fine, I personally prefer using the method on the same route but as long as its consistent across the whole API imo is doesnt really matter
Jump to solution
1 Reply
Solution
dan
dan15mo ago
either is fine, I personally prefer using the method on the same route but as long as its consistent across the whole API imo is doesnt really matter
Want results from more Discord servers?
Add your server