ivan1993spb / snake-server

Snake-Server is a pure Go implementation of the famous arcade game 🐍
https://snakeonline.xyz
MIT License
33 stars 3 forks source link

Refactor and redeclare HTTP handlers and server #56

Open ivan1993spb opened 4 years ago

ivan1993spb commented 4 years ago

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.

Helper: