Now the server object and routes are initialized in the main function and handlers are defined in the handlers module, which also contains some general business logic.
This scheme is good if there is a small server. However, the Snake-Server has become bigger and now such a scheme of the project is messy.
Refactor and redeclare HTTP handlers and server as following structure:
core/ business logic
(may be)
server/core business logic
server/
server/http/
server/http/utils/ WriteResponseJSON here
server/http/handlers/
server/http/handlers/{handler_name}
server/http/middlewares/
Prometheus metrics handler is going to be started on a special separated port which will be only for metrics and controlled by a CLI flag.
The HTTP client's handler is going to be moved from the client/ module to server/http/handlers/.
Find a new http framework which will be better then the current.
Now the server object and routes are initialized in the main function and handlers are defined in the
handlers
module, which also contains some general business logic.This scheme is good if there is a small server. However, the Snake-Server has become bigger and now such a scheme of the project is messy.
Refactor and redeclare HTTP handlers and server as following structure:
Prometheus metrics handler is going to be started on a special separated port which will be only for metrics and controlled by a CLI flag.
The HTTP client's handler is going to be moved from the
client/
module toserver/http/handlers/
.Find a new http framework which will be better then the current.
Helper:
WriteResponseJSON(w http.ResponseWriter, statusCode int, response json.Marshaler) error