-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement listener level interceptors using createInterceptors
function.
#4420
Implement listener level interceptors using createInterceptors
function.
#4420
Comments
createInterceptors
.createInterceptors
function.
|
The issue here when adding a new parameter for the public isolated function init(int port, CreateInterceptorsFunction? interceptorsFunction, *ListenerConfiguration config)
returns ListenerError? { As a solution we can add the public type ListenerConfiguration record {|
...
# interceptors - An array of interceptor services
# # Deprecated
# Defining interceptor pipeline in `http:ListenerConfiguration` is deprecated. Define the interceptor pipeline
# via `http:InterceptableService` service type
@deprecated
Interceptor|Interceptor[] interceptors?;
...
CreateInterceptorsFunction interceptorsFunction?;
|}; However this may introduce some complexities when giving compiler errors to the user if the user has defined the @shafreenAnfar @TharmiganK WDYT? Any suggestions apart from above? |
We can add the default value as public isolated function init(int port, CreateInterceptorsFunction? interceptorsFunction = (), *ListenerConfiguration config)
returns ListenerError? {
This can occur for any of these options. It is hard to give a compiler plugin warning/error here. We might have to add a runtime warning/error. There is another option to wrap the existing public isolated class InterceptableListener {
private final http:Listener httpListener;
public isolated function init(int port, CreateInterceptorsFunction interceptors,
*record{|*http:ListenerConfiguration; never interceptors?;|} config)
returns http:ListenerError? {
self.httpListener = check new(port, { ...config, interceptors: interceptors()});
}
...
} The advantage here is we have restricted the users to define the interceptors in either one of the way. So they cannot have both. |
No right? http:Listener ls = check new (5005, "localhost"); This will give an error as |
Also another option is changing This way users cannot define both at the same time. But we may have to give runtime warnings for the deprecation (however the field name does not match with the type as well). |
Yes, it will break if we have given the config map directly as the second parameter. So we have three options here:
|
Decided go ahead with option 2 |
Decided to stop supporting interceptors in listener level.
|
Description:
For the discussion see #4300
The text was updated successfully, but these errors were encountered: