Skip to content

Commit d82d815

Browse files
committed
Bump to v0.1.265; switch macros to rustapi_rs
Release bump to v0.1.265 (Cargo.toml & Cargo.lock) and add RELEASE_NOTES_v0.1.265.md. Update public API examples and procedural-macro references from `rustapi::` to `rustapi_rs::` across README/docs/crates to reflect namespace changes. Add polish and expanded usage/docs content for multiple crates (cargo-rustapi, rustapi-core, extras, jobs, macros, openapi, testing, toon, validate, view, ws) and cookbook pages. Include CLI fixes summarized in release notes (positional name for `cargo rustapi new`, migrate command timeout fix, and doc test adjustment).
1 parent 89281a5 commit d82d815

File tree

28 files changed

+804
-244
lines changed

28 files changed

+804
-244
lines changed

CHANGELOG.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ This release delivers a **12x performance improvement**, bringing RustAPI from ~
5454
- **Unified Response Body**: Refactored `rustapi-core` to use a unified `Body`/`ResponseBody` abstraction for full and streaming responses. Standardized middleware and cache layers.
5555
- **Streaming Behavior**: Clarified flow behavior for streaming responses (e.g., explicit `Transfer-Encoding: chunked`).
5656
- **Server Lifecycle**: Added graceful shutdown signal method for better lifecycle control.
57-
- **OpenAPI Path Params**: Added support for custom schema type overrides for path parameters via `#[rustapi::param]` and `.param()`.
57+
- **OpenAPI Path Params**: Added support for custom schema type overrides for path parameters via `#[rustapi_rs::param]` and `.param()`.
5858

5959
### Fixed
6060
- **Validation Groups**: Fixed logic for default group application and context boundaries.
@@ -228,16 +228,16 @@ This release delivers a **12x performance improvement**, bringing RustAPI from ~
228228
- Response types with automatic serialization
229229
- Async handler support
230230
- Basic error handling with `ApiError`
231-
- `#[rustapi::get]`, `#[rustapi::post]` route macros
232-
- `#[rustapi::main]` async main macro
231+
- `#[rustapi_rs::get]`, `#[rustapi_rs::post]` route macros
232+
- `#[rustapi_rs::main]` async main macro
233233

234234
#### Phase 2: Validation & OpenAPI
235235
- Automatic OpenAPI spec generation
236236
- Swagger UI at `/docs` endpoint
237237
- Request validation with validator crate
238238
- `#[validate]` attribute support
239239
- 422 Unprocessable Entity for validation errors
240-
- `#[rustapi::tag]` and `#[rustapi::summary]` macros
240+
- `#[rustapi_rs::tag]` and `#[rustapi_rs::summary]` macros
241241
- Schema derivation for request/response types
242242

243243
#### Phase 3: Batteries Included

Cargo.lock

Lines changed: 12 additions & 12 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
@@ -16,7 +16,7 @@ members = [
1616
]
1717

1818
[workspace.package]
19-
version = "0.1.233"
19+
version = "0.1.265"
2020
edition = "2021"
2121
authors = ["RustAPI Contributors"]
2222
license = "MIT OR Apache-2.0"
@@ -138,3 +138,4 @@ inherits = "release"
138138
debug = true
139139
strip = false
140140

141+

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ use rustapi_rs::prelude::*;
5555
#[derive(Serialize, Schema)]
5656
struct Message { text: String }
5757

58-
#[rustapi::get("/hello/{name}")]
58+
#[rustapi_rs::get("/hello/{name}")]
5959
async fn hello(Path(name): Path<String>) -> Json<Message> {
6060
Json(Message { text: format!("Hello, {}!", name) })
6161
}
6262

63-
#[rustapi::main]
63+
#[rustapi_rs::main]
6464
async fn main() {
6565
// 1 line to rule them all: Auto-discovery, OpenAPI, Validation
6666
RustApi::auto().run("127.0.0.1:8080").await

crates/cargo-rustapi/README.md

Lines changed: 28 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,48 @@
11
# cargo-rustapi
22

3-
**The official CLI tool for the RustAPI framework.**
3+
**Lens**: "The Architect"
4+
**Philosophy**: "Scaffolding best practices from day one."
45

5-
Use this tool to scaffold new projects, generate code, and fast-track your development workflow.
6+
The RustAPI CLI isn't just a project generator; it's a productivity multiplier.
67

78
## 📦 Installation
89

910
```bash
1011
cargo install cargo-rustapi
1112
```
1213

13-
## 🛠️ Usage
14+
## 🛠️ Commands
1415

15-
### Creating a New Project
16+
| Command | Description |
17+
|---------|-------------|
18+
| `cargo rustapi new <name>` | Create a new project with the perfect directory structure |
19+
| `cargo rustapi run` | Run the development server |
20+
| `cargo rustapi run --reload` | Run with hot-reload (auto-rebuild on file changes) |
21+
| `cargo rustapi generate resource <name>` | Scaffold a new API resource (Model + Handlers + Tests) |
22+
| `cargo rustapi client --spec <path> --language <lang>` | Generate a client library (Rust, TS, Python) from OpenAPI spec |
23+
| `cargo rustapi deploy <platform>` | Generate deployment configs for Docker, Fly.io, Railway, or Shuttle |
24+
| `cargo rustapi migrate <action>` | Database migration commands (create, run, revert, status, reset) |
1625

17-
Use the `new` command to generate a project structure.
26+
## 🚀 Quick Start
1827

1928
```bash
20-
# Interactive mode (Recommended)
21-
cargo rustapi new my-app
22-
23-
# Quick start with specific template
29+
# Create a new project
2430
cargo rustapi new my-app --template api
25-
```
26-
27-
**Available Templates:**
28-
- `minimal`: Basic `main.rs` and `Cargo.toml`.
29-
- `api`: REST API structure with separated `handlers` and `models`.
30-
- `web`: Web application with HTML templates (`rustapi-view`).
31-
- `full`: Complete example with Database, Auth, and Docker support.
3231

33-
### Running Development Server
34-
35-
Run your application with hot-reloading (requires `cargo-watch`).
36-
37-
```bash
38-
cargo rustapi run
32+
# Run with auto-reload
33+
cd my-app
34+
cargo rustapi run --reload
3935
```
4036

41-
### Code Generation
42-
43-
Save time by generating boilerplate.
37+
## 📁 Templates
4438

45-
```bash
46-
# Generate a handler function and register it
47-
cargo rustapi generate handler users
48-
49-
# Generate a database model
50-
cargo rustapi generate model User
51-
52-
# Generate a full CRUD resource (Model + Handlers + Tests)
53-
cargo rustapi generate crud product
54-
```
39+
The templates used by the CLI are opinionated but flexible. They enforce:
40+
- Modular folder structure
41+
- Implementation of `State` pattern
42+
- Separation of `Error` types
5543

56-
### Managing Migrations (Planned)
57-
58-
```bash
59-
cargo rustapi migrate run
60-
cargo rustapi migrate revert
61-
```
44+
**Available Templates:**
45+
- `minimal`: Basic `main.rs` and `Cargo.toml`
46+
- `api`: REST API structure with separated `handlers` and `models`
47+
- `web`: Web application with HTML templates (`rustapi-view`)
48+
- `full`: Complete example with Database, Auth, and Docker support

crates/rustapi-core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,4 @@ http3-dev = ["http3", "dep:rcgen"]
106106

107107

108108

109+

crates/rustapi-core/README.md

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,58 @@
1-
# RustAPI Core
1+
# rustapi-core
22

3-
**The internal engine of the RustAPI framework.**
3+
**Lens**: "The Engine"
4+
**Philosophy**: "The foundational crate that glues everything together."
45

56
> ⚠️ **Warning**: Most users should depend on `rustapi-rs` instead of using this crate directly. This crate's API is subject to change to support the higher-level facade.
67
7-
## Overview
8+
## Core Responsibilities
89

9-
`rustapi-core` handles the low-level HTTP mechanics, leveraging the best-in-class Rust async ecosystem:
10+
1. **Routing**: Mapping HTTP requests to Handlers
11+
2. **Extraction**: The `FromRequest` trait definition
12+
3. **Response**: The `IntoResponse` trait definition
13+
4. **Middleware**: The `Layer` and `Service` integration with Tower
14+
5. **HTTP/3**: Built-in QUIC support via `h3` and `quinn` (optional feature)
1015

11-
- **Hyper 1.0**: For robust, correct HTTP/1 and HTTP/2 implementation.
12-
- **Matchit**: For extremely fast URL routing (radix tree based).
13-
- **Tower**: For middleware composition (Service, Layer).
14-
- **Tokio**: For the async runtime.
16+
## The `Router` Internals
1517

16-
## Key Concepts
18+
We use `matchit`, a high-performance **Radix Tree** implementation for routing.
1719

18-
### The `RustApi` Builder
19-
Responsible for assembling routes, middleware, and starting the Hyper server.
20+
### Why Radix Trees?
21+
- **Speed**: Lookup time is proportional to the length of the path, not the number of routes
22+
- **Priority**: Specific paths (`/users/profile`) always take precedence over wildcards (`/users/{id}`)
23+
- **Parameters**: Efficiently parses named parameters like `{id}` or `*path` without regular expressions
2024

21-
### The `Handler` Trait
22-
The magic that allows functions with arbitrary arguments (extractors) to be used as request handlers.
25+
## The `Handler` Trait Magic
2326

24-
```rust
25-
// This function...
26-
async fn my_handler(Json(body): Json<MyData>) -> impl Responder { ... }
27+
The `Handler` trait is what allows you to write functions with arbitrary arguments:
2728

28-
// ...is converted into a Tower Service via the Handler trait.
29+
```rust
30+
// This looks simple...
31+
async fn my_handler(state: State<Db>, json: Json<Data>) { ... }
32+
33+
// ...but under the hood, it compiles to something like:
34+
impl Handler for my_handler {
35+
fn call(req: Request) -> Future<Output=Response> {
36+
// 1. Extract State
37+
// 2. Extract Json
38+
// 3. Call original function
39+
// 4. Convert return to Response
40+
}
41+
}
2942
```
3043

31-
### Extractors
32-
`FromRequest` and `FromRequestParts` traits are defined here. They allow type-safe extraction of data from HTTP requests.
44+
This is achieved through **recursive trait implementations** on tuples. RustAPI supports handlers with up to **16 arguments**.
45+
46+
## Middleware Architecture
47+
48+
`rustapi-core` is built on top of `tower`. This means any standard Tower middleware works out of the box.
49+
50+
```rust
51+
// The Service stack looks like an onion:
52+
// Outer Layer (Timeout)
53+
// -> Middle Layer (Trace)
54+
// -> Inner Layer (Router)
55+
// -> Handler
56+
```
3357

34-
- `Json<T>`
35-
- `Query<T>`
36-
- `Path<T>`
37-
- `State<T>`
58+
When you call `.layer()`, you are wrapping the inner service with a new outer layer.

0 commit comments

Comments
 (0)