0.4.0
What's Changed
- [BREAKING] Renamed Guards decorator to UseGuards decorator by @eadwinCode in #93
New Features
- Background Task Feature by @eadwinCode in #91
You can inject BackgroundTasks instance to you route handler
async def send_welcome_email(email):
print(f'Send Welcome Email Task Called with "{email}"')
@router.post('/signup')
def sign_up(username: str, password: str, email: str, tasks: BackgroundTasks):
tasks.add_task(send_welcome_email, email=email)
return {'status': 'Signup successful'}- EllarInterceptors by @eadwinCode in #92
Use of interceptors to add more custom implementation to your route handlers and controller as define by Aspect Oriented Programming (AOP) technique
@injectable
class ResponseModifierInterceptor(EllarInterceptor):
async def intercept(
self, context: IExecutionContext, next_interceptor: t.Callable[..., t.Coroutine]
) -> t.Any:
data = await next_interceptor()
if data:
data.update(ResponseModifierInterceptor="ResponseModifierInterceptor modified returned resulted")
return data
@Controller("")
class InterceptorControllerTest(ControllerBase):
@UseInterceptors(ResponseModifierInterceptor)
@get("/interceptor-1")
async def interceptor_1(self):
return {"message": "intercepted okay"}Full Changelog: 0.3.8...0.4.0