Refactor: Move main switch into main()
Refactor: Endpoints in separate functions, dynamically selected in main()