site/docs/basics/controller.md
Typically, web applications adopt the MVC architecture, where C stands for Controller, which is responsible for parsing user input, processing it, and returning the corresponding result.
In simple terms, when you need to add an interface that provides services such as HTTP to the application, use the corresponding Controller decorator to define and implement it.
After implementing an HTTPController, clients can request the server's controller via HTTP protocol. After the controller completes processing, it responds to the client. This is the most basic "request-response" flow.
Generally speaking, Controllers should not contain too much business logic and should only handle protocol-related processing.
Egg provides different Controller decorators for implementing different types of interfaces, which can be selected based on requirements.
| Controller Decorator | Description |
|---|---|
| @HTTPController / @HTTPMethod | Used to implement HTTP interfaces |
| @MCPController | Used to implement MCP Server |
| @Schedule | Used for standard apps to implement scheduled tasks |