Skip to content

Add configured client copies with request and response callbacks - #605

Merged
dblock merged 1 commit into
slack-ruby:masterfrom
dblock:request-response-block
Oct 5, 2026
Merged

dblock merged 1 commit into
slack-ruby:masterfrom
dblock:request-response-block

Conversation

@dblock

@dblock dblock commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

Usage

observed = client.with_request do |request|
  request.headers["X-Custom"] = "value"
end
observed = observed.with_response do |response|
  scopes = response.headers["x-oauth-scopes"]&.split(",")&.map(&:strip)
end

result = observed.auth_test
observed.users_list do |page|
  puts page.members
end

Behavior

  • Both methods return configured client copies with independent connections; the original is unchanged.
  • Callbacks cover every HTTP request, including pagination and helper calls. Existing return values and endpoint blocks are unchanged.
  • Request callbacks run after request configuration and before dispatch. Response callbacks run after successful completion with parsed body, headers, and status.
  • Chaining appends callbacks in registration order. Callback exceptions propagate; response callbacks do not run on Slack or transport errors.
  • No generator, generated endpoint, or patch-file changes are needed with this revised design.

Validation

632 non-CLI specs pass and RuboCop reports no offenses. CLI specs remain excluded locally because an existing Bundler warning contaminates subprocess output. Existing submodule changes are excluded.

Follow-up to #382. Prepared by an AI on behalf of @dblock.

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Danger Report

No issues found.

View run

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dblock dblock changed the title Expose response callbacks through request configuration blocks Add configured client copies with request and response callbacks Oct 5, 2026
@dblock
dblock force-pushed the request-response-block branch from d969dfb to fad8c07 Compare October 5, 2026 12:51
@dblock
dblock merged commit b771787 into slack-ruby:master Oct 5, 2026
12 checks passed
@dblock
dblock deleted the request-response-block branch October 5, 2026 12:54
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 37312481885

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.1%) to 91.178%

Details

  • Coverage increased (+0.1%) from the base build.
  • Patch coverage: 92 of 92 lines across 3 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 6087
Covered Lines: 5550
Line Coverage: 91.18%
Coverage Strength: 102.83 hits per line

💛 - Coveralls

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