Skip to content

Commit 20cece7

Browse files
authored
Merge pull request #12 from Tuntii/hot-fix
Refactor path params and optimize JSON handling
2 parents 3d06ec8 + 255d956 commit 20cece7

File tree

10 files changed

+268
-20
lines changed

10 files changed

+268
-20
lines changed

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ jobs:
1515
name: Test
1616
runs-on: ubuntu-latest
1717
steps:
18+
- name: Free disk space
19+
run: |
20+
sudo rm -rf /usr/share/dotnet
21+
sudo rm -rf /opt/ghc
22+
sudo rm -rf /usr/local/share/boost
23+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
24+
df -h
25+
1826
- uses: actions/checkout@v4
1927

2028
- name: Install Rust
@@ -41,6 +49,14 @@ jobs:
4149
name: Lint
4250
runs-on: ubuntu-latest
4351
steps:
52+
- name: Free disk space
53+
run: |
54+
sudo rm -rf /usr/share/dotnet
55+
sudo rm -rf /opt/ghc
56+
sudo rm -rf /usr/local/share/boost
57+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
58+
df -h
59+
4460
- uses: actions/checkout@v4
4561

4662
- name: Install Rust
@@ -69,6 +85,14 @@ jobs:
6985
name: Build
7086
runs-on: ubuntu-latest
7187
steps:
88+
- name: Free disk space
89+
run: |
90+
sudo rm -rf /usr/share/dotnet
91+
sudo rm -rf /opt/ghc
92+
sudo rm -rf /usr/local/share/boost
93+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
94+
df -h
95+
7296
- uses: actions/checkout@v4
7397

7498
- name: Install Rust
@@ -98,6 +122,14 @@ jobs:
98122
name: Documentation
99123
runs-on: ubuntu-latest
100124
steps:
125+
- name: Free disk space
126+
run: |
127+
sudo rm -rf /usr/share/dotnet
128+
sudo rm -rf /opt/ghc
129+
sudo rm -rf /usr/local/share/boost
130+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
131+
df -h
132+
101133
- uses: actions/checkout@v4
102134

103135
- name: Install Rust

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@
77
assets/myadam.jpg
88
.github/copilot-instructions.md
99
docs/UPDATE_SUMMARIES.md
10+
assets/cb7d0daf60d7675081996d81393e2ae5.jpg
11+
assets/b9c93c1cd427d8f50e68dbd11ed2b000.jpg

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.1.8] - 2026-01-10
11+
12+
### Added
13+
- **CORS middleware**: `CorsLayer` with full `MiddlewareLayer` trait implementation
14+
- Support for `CorsLayer::permissive()` and custom configuration
15+
- Proper preflight request handling
16+
- Origin validation and credential support
17+
18+
### Fixed
19+
- Fixed missing `MiddlewareLayer` implementation for `CorsLayer`
20+
- Fixed CI build issues with GitHub Actions runner disk space
21+
1022
## [0.1.4] - 2026-01-03
1123

1224
### Added

Cargo.lock

Lines changed: 22 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ members = [
2424
# "examples/graphql-api", # TODO: Needs API updates
2525
"examples/microservices",
2626
"examples/middleware-chain",
27+
"examples/cors-test",
2728
"benches/toon_bench",
2829
]
2930

3031
[workspace.package]
31-
version = "0.1.7"
32+
version = "0.1.8"
3233
edition = "2021"
3334
authors = ["RustAPI Contributors"]
3435
license = "MIT OR Apache-2.0"

crates/rustapi-core/src/app.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,7 @@ impl RustApi {
266266
entry.insert_boxed_with_operation(method_enum, route.handler, route.operation);
267267
}
268268

269-
let route_count = by_path
270-
.values()
271-
.map(|mr| mr.allowed_methods().len())
272-
.sum::<usize>();
269+
let route_count: usize = by_path.values().map(|mr| mr.allowed_methods().len()).sum();
273270
let path_count = by_path.len();
274271

275272
for (path, method_router) in by_path {

crates/rustapi-core/src/extract.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ impl<T> ValidatedJson<T> {
199199

200200
impl<T: DeserializeOwned + rustapi_validate::Validate + Send> FromRequest for ValidatedJson<T> {
201201
async fn from_request(req: &mut Request) -> Result<Self> {
202-
// First, deserialize the JSON body
203202
let body = req
204203
.take_body()
205204
.ok_or_else(|| ApiError::internal("Body already consumed"))?;
@@ -778,10 +777,17 @@ impl<T: for<'a> Schema<'a>> OperationModifier for Json<T> {
778777
}
779778
}
780779

781-
// Path - Placeholder for path params
780+
// Path - Path parameters are automatically extracted from route patterns
781+
// The add_path_params_to_operation function in app.rs handles OpenAPI documentation
782+
// based on the {param} syntax in route paths (e.g., "/users/{id}")
782783
impl<T> OperationModifier for Path<T> {
783784
fn update_operation(_op: &mut Operation) {
784-
// TODO: Implement path param extraction
785+
// Path parameters are automatically documented by add_path_params_to_operation
786+
// in app.rs based on the route pattern. No additional implementation needed here.
787+
//
788+
// For typed path params, the schema type defaults to "string" but will be
789+
// inferred from the actual type T when more sophisticated type introspection
790+
// is implemented.
785791
}
786792
}
787793

0 commit comments

Comments
 (0)