Concepts: Controllers (Core)
In this section we shall discuss the concept of a controller within the Sodacore framework.
Introduction
A controller is a class (or collection) of methods that will handle an incoming event, and dispatch a response.
Think of a controller as a location for your business logic, now when I say business logic, I don't mean that you should put all your code in here, but rather the logic that is specific to the request being handled, Providers are a great place to put reusable logic that can be used across multiple controllers or even just normal classes, but in general, think of a controller that follows the MVC pattern, where the controller essentially is your entry and exit point.
Within the core package alone, the only concept is a controller for threads, however in other plugins, like HTTP, WebSockets and more, the concept stays the same, but the request and response type changes.
As of right now, the controllers for threads
aren't documented, and this is because the API is going to change - but until a valid use case is found, they will remain as is - undocumented.
For now though, in all cases related to the sodacore framework, a controller, whether that be for HTTP, WebSockets, or other plugins, is simply a class that contains methods that handle incoming requests/events and return responses.
For now, to look at real-world use cases for controllers, check out the HTTP Controllers and WebSocket Controllers sections.