Skip to content

Conversation

@m4tx
Copy link
Member

@m4tx m4tx commented Jan 19, 2026

No description provided.

@github-actions github-actions bot added C-lib Crate: cot (main library crate) C-macros Crate: cot-macros labels Jan 19, 2026
@m4tx m4tx mentioned this pull request Jan 19, 2026
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 refactors the codebase to remove convenience methods from the RequestExt trait (db(), cache(), email()) and replaces them with a more idiomatic extractor pattern. This is a breaking change that improves code consistency by having all framework services accessed via extractors rather than a mix of trait methods and extractors.

Changes:

  • Removed db(), cache(), and email() methods from RequestExt trait
  • Added FromRequestHead implementations for Database, Cache, and Email types
  • Updated example code and documentation to use the new extractor pattern

Reviewed changes

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

Show a summary per file
File Description
examples/send-email/src/main.rs Updated to use email_service as a function parameter (extractor) instead of calling request.email()
cot/tests/extractors.rs Added new integration tests demonstrating cache and email extractors
cot/src/request/extractors.rs Implemented FromRequestHead for Database, Cache, and Email types; added unit tests
cot/src/request.rs Removed db(), cache(), and email() methods from RequestExt and removed related tests
cot/src/project.rs Updated documentation example to reflect the removal of request.db() shortcut
cot/src/db/relations.rs Updated documentation example to use Database extractor instead of request.db()
cot/src/auth/db.rs Updated documentation examples to use Database extractor in function signatures
cot-macros/src/admin.rs Updated generated code to use request.context().database() instead of request.db()

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

/// ```
/// use cot::db::{Auto, ForeignKey, Model, model};
/// use cot::db::{Auto, Database, ForeignKey, Model, model};
/// use cot::request::{Request, RequestExt};
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The import of RequestExt is no longer needed in this documentation example since the code now uses the Database extractor directly instead of request.db(). Consider removing RequestExt from the import statement.

Suggested change
/// use cot::request::{Request, RequestExt};

Copilot uses AI. Check for mistakes.
/// use cot::common_types::Password;
/// use cot::db::Database;
/// use cot::html::Html;
/// use cot::request::{Request, RequestExt};
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The imports of Request and RequestExt are no longer needed in this documentation example since the code now uses the Database extractor directly. Consider removing these unused imports from the import statement.

Suggested change
/// use cot::request::{Request, RequestExt};

Copilot uses AI. Check for mistakes.
/// use cot::common_types::Password;
/// use cot::db::Database;
/// use cot::html::Html;
/// use cot::request::{Request, RequestExt};
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

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

The imports of Request and RequestExt are no longer needed in this documentation example since the code now uses the Database extractor directly. Consider removing these unused imports from the import statement.

Suggested change
/// use cot::request::{Request, RequestExt};

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Jan 19, 2026

🐰 Bencher Report

Branchrequest-ext-cleanup
Testbedgithub-ubuntu-latest
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
microseconds (µs)
(Result Δ%)
Upper Boundary
microseconds (µs)
(Limit %)
empty_router/empty_router📈 view plot
🚷 view threshold
6,170.70 µs
(+1.96%)Baseline: 6,051.92 µs
6,863.83 µs
(89.90%)
json_api/json_api📈 view plot
🚷 view threshold
1,032.10 µs
(+0.96%)Baseline: 1,022.30 µs
1,140.75 µs
(90.48%)
nested_routers/nested_routers📈 view plot
🚷 view threshold
946.72 µs
(+0.24%)Baseline: 944.41 µs
1,049.20 µs
(90.23%)
single_root_route/single_root_route📈 view plot
🚷 view threshold
906.39 µs
(+0.26%)Baseline: 904.04 µs
1,003.48 µs
(90.32%)
single_root_route_burst/single_root_route_burst📈 view plot
🚷 view threshold
17,116.00 µs
(-2.41%)Baseline: 17,537.84 µs
20,808.28 µs
(82.26%)
🐰 View full continuous benchmarking report in Bencher

Copy link
Member

@seqre seqre left a comment

Choose a reason for hiding this comment

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

Actually, a change of mind. It should be deprecated and removed in the next release, just like we did it last time.

@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 90.47619% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cot/src/request.rs 0.00% 2 Missing ⚠️
Flag Coverage Δ
rust 90.36% <90.47%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cot-macros/src/admin.rs 89.58% <ø> (ø)
cot/src/auth/db.rs 85.21% <ø> (ø)
cot/src/db/relations.rs 91.66% <ø> (ø)
cot/src/project.rs 88.10% <ø> (ø)
cot/src/request/extractors.rs 92.38% <100.00%> (+0.71%) ⬆️
cot/src/request.rs 93.65% <0.00%> (-2.59%) ⬇️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@ElijahAhianyo ElijahAhianyo left a comment

Choose a reason for hiding this comment

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

Ah Nice, this looks like a better approach

@m4tx m4tx merged commit 9d5976a into master Jan 19, 2026
39 of 40 checks passed
@m4tx m4tx deleted the request-ext-cleanup branch January 19, 2026 18:51
@cotbot cotbot bot mentioned this pull request Jan 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-lib Crate: cot (main library crate) C-macros Crate: cot-macros

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants