Skip to content

feat: initial support for route and HTTP method introspection #3594

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

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

dertin
Copy link

@dertin dertin commented Mar 3, 2025

PR Type

Feature

PR Checklist

  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • A changelog entry has been made for the appropriate packages.
  • Format code with the latest stable rustfmt.
  • (Team) Label with affected crates and semver status.

Overview

Hello, this is my first contribution to the project. This PR introduces a new resource introspection feature for actix-web that allows retrieving all configured route paths along with their associated HTTP methods after the server has started. Currently, it supports only basic Guards that determine HTTP methods. The feature is activated using the experimental-introspection feature flag.

I developed this feature because it's extremely useful for auditing services with many route paths that change constantly. I hope it proves valuable for others as well, and I welcome any feedback or suggestions for improvement.

Closes #1462
Closes #2677

@dertin
Copy link
Author

dertin commented Mar 4, 2025

Hi, @robjtede

Here's a limited-scope approach for listing routes and methods from the Guards it’s a starting point.
Extending support to extract additional metadata might require more breaking changes
(potentially involving proc-macro / actix-web-codegen).

Please review and let me know your thoughts!

dertin added 3 commits March 5, 2025 02:34
… usage

- Added `GuardDetail` enum to encapsulate various introspection details of a guard.
- Refactored `HttpMethodsExtractor` implementation to use `GuardDetail` instead of `downcast_ref`.
… usage

- Added `GuardDetail` enum to encapsulate various introspection details of a guard.
- Refactored `HttpMethodsExtractor` implementation to use `GuardDetail` instead of `downcast_ref`.
@dertin dertin changed the title feat(resources-introspection): add support for resource metadata retrieval feat(resources-introspection): initial support for route and HTTP method introspection Mar 5, 2025
@dertin dertin marked this pull request as draft May 1, 2025 06:51
@robjtede robjtede changed the title feat(resources-introspection): initial support for route and HTTP method introspection feat: initial support for route and HTTP method introspection May 9, 2025
@robjtede robjtede added B-semver-minor A-web project: actix-web labels May 9, 2025
devdertin added 5 commits May 12, 2025 02:29
… `experimental-introspection`

- Refactored introspection logic.
- Enhanced route introspection to register HTTP methods and guard names.
- Added example for testing the experimental introspection feature.
@dertin dertin marked this pull request as ready for review May 19, 2025 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-web project: actix-web B-semver-minor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

way to get a list of registered services Route introspection
3 participants