Skip to content

Ellar Interceptors - #92

Merged
eadwinCode merged 10 commits into
mainfrom
interceptors
May 29, 2023
Merged

Ellar Interceptors#92
eadwinCode merged 10 commits into
mainfrom
interceptors

Conversation

@eadwinCode

@eadwinCode eadwinCode commented May 24, 2023

Copy link
Copy Markdown
Collaborator

Whats new

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

The above construct will return

status: 200,
{
    "ResponseModifierInterceptor": "ResponseModifierInterceptor modified returned resulted",
    "message": "intercepted okay",
}

@codecov-commenter

codecov-commenter commented May 26, 2023

Copy link
Copy Markdown

Codecov Report

Merging #92 (59086c5) into main (ceb3bcf) will increase coverage by 0.34%.
The diff coverage is 99.66%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##             main      #92      +/-   ##
==========================================
+ Coverage   97.35%   97.69%   +0.34%     
==========================================
  Files         223      232       +9     
  Lines        6607     6679      +72     
==========================================
+ Hits         6432     6525      +93     
+ Misses        175      154      -21     
Impacted Files Coverage Δ
ellar/common/__init__.py 100.00% <ø> (ø)
ellar/common/commands/base.py 100.00% <ø> (+22.22%) ⬆️
ellar/common/commands/decorator.py 100.00% <ø> (+50.00%) ⬆️
ellar/common/decorators/middleware.py 100.00% <ø> (ø)
ellar/common/routing/__init__.py 100.00% <ø> (ø)
ellar/core/context/execution.py 100.00% <ø> (ø)
ellar/core/context/factory.py 100.00% <ø> (ø)
ellar/di/service_config.py 100.00% <ø> (ø)
ellar/socket_io/testing/module.py 100.00% <ø> (ø)
ellar/common/routing/base.py 94.23% <93.75%> (-2.65%) ⬇️
... and 41 more

... and 5 files with indirect coverage changes

@eadwinCode
eadwinCode merged commit d54f5d7 into main May 29, 2023
@eadwinCode eadwinCode changed the title WIP: Ellar Interceptors Ellar Interceptors May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants