When you create a new Content type or a new model. You will see a new empty controller as been created. It is because Strapi builds a generic api for your models by default and allows you to override and extend it in the generated files.
### Extending a Model Controller
Here are the core methods (and there current implementation).
You can simply copy and paste this code in your own controller file to customize the methods.
#### `find`
```js
module.exports = {
/**
* Retrieve records.
*
*@return {Object|Array}
*/
find(ctx) {
if (ctx.query._q) {
return service.search(ctx.query);
}
return service.find(ctx.query);
},
};
```
## Custom controllers
You can also add controller outisde of Content Types to build custom business logic and Api endpoints.
- Using the CLI `strapi generate:controller products`. Read the [CLI documentation](../cli/CLI.md#strapi-generatecontroller) for more information.
- Manually create a JavaScript file in `./api/**/controllers`.
### Adding Endpoints
Each controller’s action must be an `async` function.
Every action receives a `context` (`ctx`) object as first parameter containing the [request context](../guides/requests.md) and the [response context](../guides/responses.md).