What are the different types of API endpoints?
What are API endpoints and why are they important?
How should I version REST API endpoints?
I have touble understanding how to differentiate between both and whats their use case and difference anyway? whats makes a URL an API endpoints and why is that advantageous over just having a certain web page with some functionality at a certain path?
I have around 10 API endpoints and they share quite a few lines of similar code.
My current folder structure for the API endpoint handlers look like this:
handlers\add\add.go
handlers\delete\delete.go
...
At the beginning and end of each endpoint I do the same things (validation, logging...). I want to create functions for these because I just copy-pasted them to each file.
Where should I store these functions? My idea is to create a common folder:
handlers\common\common.go
Is it a good practice or should I name it differently?
Should I put it into the handlers folder or somewhere else?
I know there are many solutions for this but I'm looking for good practice.
I wanted to create middlewares first but I use the result of these later in the code so that's not a good solution as I would have to pass the result of the middleware to the endpoint handler.