Skip to content

Commit 108592f

Browse files
authored
Update README.md
1 parent 85694f2 commit 108592f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,25 @@ class CarModule(ModuleBase):
221221
pass
222222
```
223223

224+
## Registering Module
225+
Ellar is not aware of `CarModule` yet, so we need to add it to the `modules` list of `ApplicationModule` at the `carsite/root_module.py`.
226+
```python
227+
from ellar.common import Module, exception_handler
228+
from ellar.core import ModuleBase
229+
from ellar.core.connection import Request
230+
from ellar.core.response import JSONResponse, Response
231+
232+
from ellar.samples.modules import HomeModule
233+
from .apps.car.module import CarModule
224234

235+
236+
@Module(modules=[HomeModule, CarModule])
237+
class ApplicationModule(ModuleBase):
238+
@exception_handler(404)
239+
def exception_404_handler(cls, request: Request, exc: Exception) -> Response:
240+
return JSONResponse(dict(detail="Resource not found."))
241+
242+
```
225243
## Enabling OpenAPI Docs
226244
To start up openapi, we need to go back to project folder in the `server.py`
227245
then add the following below.

0 commit comments

Comments
 (0)