Skip to content

Pre-route set_middleware hook (CORS preflight) — issue #11 - #37

Merged
ZhuchkaTriplesix merged 2 commits into
devfrom
issue-11-middleware
Apr 26, 2026
Merged

ZhuchkaTriplesix merged 2 commits into
devfrom
issue-11-middleware

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Closes #11

  • App.set_middleware / AppState::middleware: one optional (scope, protocol) callback that runs after method/path are known, before body read and routing.
  • Return None to continue; any other return value is mapped like a route handler and sent (short-circuit).
  • send_handler_map shared for middleware and normal handler path.
  • Doc note in docs/handlers.md; ASGI test: OPTIONS preflight 204, POST handler not invoked.

Wire AppState.middleware in dispatch: call (scope, protocol) after path/method
and before body read; None continues, other values use handler response mapping.
Factor send_handler_map for reuse. Document in handlers.md; add ASGI CORS test.
@ZhuchkaTriplesix ZhuchkaTriplesix linked an issue Apr 26, 2026 that may be closed by this pull request

@ZhuchkaTriplesix ZhuchkaTriplesix left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

123

@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit 41ddb43 into dev Apr 26, 2026
16 checks passed
@ZhuchkaTriplesix
ZhuchkaTriplesix deleted the issue-11-middleware branch April 26, 2026 16:08
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.

feat: optional middleware chain in run_rsgi before route match

1 participant