Skip to content

Add an easier way to access X-Slack-Retry-Num / X-Slack-Retry-Reason in Bolt apps #676

@seratch

Description

@seratch

We can add X-Slack-Retry-Num and X-Slack-Retry-Reason values to com.slack.api.bolt.context.builtin.EventContext class.


~jayyhkwon Ah ... you are right. I have to say there is no way to directly access request headers in listeners. I will take a look at possible ways to support this use case in the future versions. As a workaround, you can use a global middleware this way:

app.use((req, resp, chain) -> {
  String retryNum = req.getHeaders().getFirstValue("X-Slack-Retry-Num");
  req.getContext().getAdditionalValues().put("x-slack-retry-num", retryNum);
  return chain.next(req);
});
app.event(AppMentionEvent.class, (req, ctx) -> {
  String retryNum = ctx.getAdditionalValues().get("x-slack-retry-num");
  return ctx.ack();
});

Originally posted by @seratch in #646 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions