Skip to content

Conversation

@Tuntii
Copy link
Owner

@Tuntii Tuntii commented Jan 10, 2026

Replaces HashMap usage with PathParams for request path parameters throughout core and middleware modules. Switches JSON parsing and serialization to use simd-json for improved performance and adds buffer pre-allocation for responses. Implements CORS middleware logic in rustapi-extras, handling preflight and actual requests with correct headers. Updates tests to use PathParams.

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test addition or update
  • CI/CD changes
  • Other (please describe):

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Related Issues

Fixes #11

Testing

Please describe the tests that you ran to verify your changes:

  • Unit tests
  • Integration tests
  • Manual testing
  • Other (please describe):

Replaces HashMap usage with PathParams for request path parameters throughout core and middleware modules. Switches JSON parsing and serialization to use simd-json for improved performance and adds buffer pre-allocation for responses. Implements CORS middleware logic in rustapi-extras, handling preflight and actual requests with correct headers. Updates tests to use PathParams.
Copilot AI review requested due to automatic review settings January 10, 2026 12:38
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to refactor path parameter handling from HashMap to a new PathParams type and switch to simd-json for improved JSON performance. It also implements CORS middleware logic in rustapi-extras. However, the PR has critical compilation errors that prevent it from being merged.

Changes:

  • Attempts to replace HashMap with PathParams for request path parameters in tests
  • Attempts to switch JSON parsing/serialization to use a new json module (not included in PR)
  • Implements CORS middleware with preflight and actual request handling
  • Adds two image files to .gitignore

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 23 comments.

Show a summary per file
File Description
crates/rustapi-extras/src/cors/mod.rs Implements MiddlewareLayer trait for CorsLayer with preflight and actual request handling
crates/rustapi-core/src/middleware/tracing_layer.rs Updates test to use non-existent PathParams type
crates/rustapi-core/src/middleware/request_id.rs Updates test to use non-existent PathParams type
crates/rustapi-core/src/middleware/layer.rs Updates test to use non-existent PathParams type
crates/rustapi-core/src/middleware/body_limit.rs Updates test to use non-existent PathParams type
crates/rustapi-core/src/extract.rs Updates tests to use non-existent PathParams type and attempts to use non-existent json module
crates/rustapi-core/src/app.rs Updates test to use non-existent PathParams type and attempts to use non-existent trace_info! macro
.gitignore Adds two image files to ignore list
Comments suppressed due to low confidence (1)

crates/rustapi-core/src/app.rs:285

  • The macro crate::trace_info! doesn't exist in the codebase. This will cause a compilation error. You should either use tracing::info! directly with the conditional compilation guard, or define the trace_info! macro.
        crate::trace_info!(
            paths = path_count,
            routes = route_count,
            "Auto-registered routes"
        );

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Bytes::new(),
Arc::new(Extensions::new()),
HashMap::new(),
PathParams::new(),
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

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

The type PathParams doesn't exist. Based on the code in request.rs, path parameters are still stored as HashMap<String, String>, not PathParams. This will cause a compilation error.

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Bytes::new(),
Arc::new(Extensions::new()),
HashMap::new(),
PathParams::new(),
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

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

The type PathParams doesn't exist. This will cause a compilation error.

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

Bytes::new(),
Arc::new(Extensions::new()),
HashMap::new(),
PathParams::new(),
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

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

The type PathParams doesn't exist. This will cause a compilation error.

Copilot uses AI. Check for mistakes.
Replaces usage of the PathParams struct with std::collections::HashMap throughout the codebase, including tests. Also removes dependency on the custom json module in favor of serde_json for JSON serialization and deserialization. Updates logging to use tracing directly instead of crate::trace_info! macro.
Reformatted the CorsLayer middleware logic to improve code readability by expanding chained method calls and aligning insertions for response headers. No functional changes were made. Minor whitespace cleanup in extract.rs and app.rs.
Copy link

Copilot AI commented Jan 10, 2026

@Tuntii I've opened a new pull request, #13, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link

Copilot AI commented Jan 10, 2026

@Tuntii I've opened a new pull request, #14, to work on those changes. Once the pull request is ready, I'll request review from you.

Introduces a new example 'cors-test' to demonstrate CORS, rate limiting, and middleware usage with rustapi-rs. Updates workspace members in Cargo.toml and bumps rustapi-related crate versions to 0.1.8.
@Tuntii Tuntii merged commit 20cece7 into main Jan 10, 2026
4 checks passed
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.

[BUG] CorsLayer does not implement MiddlewareLayer trait

2 participants