Skip to content
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

Allow asynchronous functions in an interceptor #13

Open
birdthedeveloper opened this issue Sep 28, 2024 · 0 comments
Open

Allow asynchronous functions in an interceptor #13

birdthedeveloper opened this issue Sep 28, 2024 · 0 comments

Comments

@birdthedeveloper
Copy link

In order to send a twirp RPC call, in my use case, I need to get an authentication token via asynchronous method first. It seems to me that this cannot be done with the current implementation.

Desired code, most of which taken from official interceptor example in documentation:

// This does not compile

tart.Interceptor LogInterceptor(Logger l) {
  return (Method next) {
    return (Context ctx, dynamic req) async {

      // added this line bellow
      String token = await getAuthenticationToken();

      l.print('''Service: ${ctx.value(tart.ContextKeys.serviceName)}, Method: ${ctx.value(tart.ContextKeys.methodName)}''');
      return next(ctx, req);
    };
  };
}
@birdthedeveloper birdthedeveloper changed the title Allow asynchronous functions in a interceptor Allow asynchronous functions in an interceptor Sep 28, 2024
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

No branches or pull requests

1 participant