Skip to content

Commit

Permalink
Merge pull request #1844 from ballerina-platform/interceptor-spec
Browse files Browse the repository at this point in the history
Update interceptor section of the spec
  • Loading branch information
TharmiganK authored Jan 22, 2024
2 parents 69f895f + 3cec446 commit dc250fb
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions docs/spec/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -2090,7 +2090,7 @@ service class RequestInterceptor {
resource function 'default [string… path](http:RequestContext ctx, http:Request req) returns http:NextService|error? {
req.setHeader("X-requestHeader", "RequestInterceptor");
ctx.next();
return ctx.next();
}
}
```
Expand All @@ -2108,7 +2108,7 @@ service class RequestInterceptor {
resource function 'default foo(http:RequestContext ctx, http:Request req) returns http:NextService|error? {
req.setHeader("X-requestHeader", "RequestInterceptor");
ctx.next();
return ctx.next();
}
}
```
Expand Down Expand Up @@ -2211,7 +2211,7 @@ service class ResponseInterceptor {
remote function interceptResponse(http:RequestContext ctx, http:Response res) returns http:NextService|error? {
res.setHeader("X-responseHeader", "ResponseInterceptor");
ctx.next();
return ctx.next();
}
}
```
Expand Down Expand Up @@ -2318,13 +2318,6 @@ However, if the user decides to respond at 4 and terminate the cycle, only the `
Also, when the `RequestInterceptor` at 2 returns an error, the execution jumps from 2 to 6 as the nearest Error Interceptor
is at 6. The same goes to the response path.

The execution order when interceptors are engaged at both service and listener levels is as follows:

```
ListenerLevel : RequestInterceptors -> ServiceLevel : RequestInterceptors -> TargetService ->
ServiceLevel : ResponseInterceptors -> ListenerLevel : ResponseInterceptors
```

Execution of interceptors does not depend on the existence of the end service i.e. the interceptors are executed in the
relevant order even though the end service does not exist.

Expand Down

0 comments on commit dc250fb

Please sign in to comment.