Skip to content

0.4.0

Choose a tag to compare

@eadwinCode eadwinCode released this 29 May 23:22
· 730 commits to main since this release
39f9ef7

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'}
@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