Skip to content

Commit 3559bab

Browse files
committed
Update README.md
1 parent 82da03b commit 3559bab

1 file changed

Lines changed: 28 additions & 14 deletions

File tree

README.md

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ We combine Rust's performance and safety with FastAPI's ergonomics. Write type-s
2121
```rust
2222
use rustapi_rs::prelude::*;
2323

24-
#[rustapi::get("/hello/:name")]
24+
#[rustapi_rs::get("/hello/{name}")]
2525
async fn hello(Path(name): Path<String>) -> Json<Message> {
2626
Json(Message { greeting: format!("Hello, {name}!") })
2727
}
2828

29-
#[rustapi::main]
30-
async fn main() -> Result<()> {
31-
RustApi::new().mount_route(hello_route()).docs("/docs").run("0.0.0.0:8080").await
29+
#[tokio::main]
30+
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
31+
RustApi::auto().run("0.0.0.0:8080").await
3232
}
3333
```
3434

@@ -40,7 +40,7 @@ async fn main() -> Result<()> {
4040

4141
```toml
4242
[dependencies]
43-
rustapi-rs = "0.0.5"
43+
rustapi-rs = "0.1.3"
4444
```
4545

4646
```rust
@@ -49,18 +49,16 @@ use rustapi_rs::prelude::*;
4949
#[derive(Serialize, Schema)]
5050
struct User { id: u64, name: String }
5151

52-
#[rustapi::get("/users/:id")]
52+
#[rustapi_rs::get("/users/{id}")]
5353
async fn get_user(Path(id): Path<u64>) -> Json<User> {
5454
Json(User { id, name: "Tunahan".into() })
5555
}
5656

57-
#[rustapi::main]
58-
async fn main() -> Result<()> {
59-
RustApi::new()
60-
.mount_route(get_user_route())
61-
.docs("/docs")
62-
.run("127.0.0.1:8080")
63-
.await
57+
#[tokio::main]
58+
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
59+
// Zero config: all `#[rustapi_rs::get/post/..]` routes are auto-registered.
60+
// Swagger UI is enabled at /docs by default (when built with the `swagger-ui` feature).
61+
RustApi::auto().run("127.0.0.1:8080").await
6462
}
6563
```
6664

@@ -73,6 +71,7 @@ async fn main() -> Result<()> {
7371
| Feature | Description |
7472
|---------|-------------|
7573
| **Type-Safe Extractors** | `Json<T>`, `Query<T>`, `Path<T>` — compile-time guarantees |
74+
| **Zero-Config Routing** | Macro-decorated routes auto-register at startup (`RustApi::auto()`) |
7675
| **Auto OpenAPI** | Your code = your docs. `/docs` endpoint out of the box |
7776
| **Validation** | `#[validate(email)]` → automatic 422 responses |
7877
| **JWT Auth** | One-line auth with `AuthUser<T>` extractor |
@@ -82,7 +81,7 @@ async fn main() -> Result<()> {
8281
### Optional Features
8382

8483
```toml
85-
rustapi-rs = { version = "0.0.5", features = ["jwt", "cors", "toon"] }
84+
rustapi-rs = { version = "0.1.3", features = ["jwt", "cors", "toon"] }
8685
```
8786

8887
- `jwt` — JWT authentication
@@ -93,6 +92,21 @@ rustapi-rs = { version = "0.0.5", features = ["jwt", "cors", "toon"] }
9392

9493
---
9594

95+
## Examples
96+
97+
All examples in this repository are written in the Phase 6 “zero-config” style.
98+
99+
```bash
100+
cargo run -p hello-world
101+
cargo run -p crud-api
102+
cargo run -p auth-api
103+
cargo run -p sqlx-crud
104+
cargo run -p toon-api
105+
cargo run -p proof-of-concept
106+
```
107+
108+
---
109+
96110
## 🤖 LLM-Optimized: TOON Format
97111

98112
RustAPI is built for **AI-powered APIs**.

0 commit comments

Comments
 (0)