This directory contains the in-repository examples for the rustapi-rs facade crate.
Multipart file upload with Multipart, body limits, and safe filename handling.
Run it with:
cargo run -p rustapi-rs --example file_uploadThen try:
curl -X POST http://127.0.0.1:8080/upload -F "file=@./README.md"See also the file uploads cookbook recipe.
Shows cookie-backed login, session refresh, logout, and session inspection using the built-in session middleware.
Run it with:
cargo run -p rustapi-rs --example auth_api --features extras-sessionThen try:
POST http://127.0.0.1:3000/auth/loginwith{"user_id":"demo-user"}GET http://127.0.0.1:3000/auth/mePOST http://127.0.0.1:3000/auth/refreshPOST http://127.0.0.1:3000/auth/logout
Shows a compact in-memory CRUD API with list/create/read/update/delete routes.
Run it with:
cargo run -p rustapi-rs --example full_crud_apiThen try:
GET http://127.0.0.1:3000/todosPOST http://127.0.0.1:3000/todosGET http://127.0.0.1:3000/todos/1PATCH http://127.0.0.1:3000/todos/1DELETE http://127.0.0.1:3000/todos/1
Shows Server-Sent Events (SSE) with a small progress feed.
Run it with:
cargo run -p rustapi-rs --example streaming_apiThen open:
http://127.0.0.1:3000/events
Shows an in-memory job queue, enqueue endpoint, and manual worker tick endpoint.
Run it with:
cargo run -p rustapi-rs --example jobs_api --features extras-jobsThen try:
POST http://127.0.0.1:3000/jobs/emailPOST http://127.0.0.1:3000/jobs/process-nextGET http://127.0.0.1:3000/jobs/stats
Shows typed path definitions, type-safe route registration, and URI generation with TypedPath.
Run it with:
cargo run -p rustapi-rs --example typed_path_pocShows the automatic status page and a few endpoints that generate traffic, latency, and failures for demonstration purposes.
Run it with:
cargo run -p rustapi-rs --example status_demoThen open:
http://127.0.0.1:3000/statushttp://127.0.0.1:3000/fasthttp://127.0.0.1:3000/slowhttp://127.0.0.1:3000/flaky
Demonstrates running your normal HTTP API together with a Native MCP server using in-process invocation (zero network overhead). Selected routes (those tagged "agent") are automatically exposed as discoverable tools for LLMs and agent clients (Claude, Cursor, etc.). Tool calls go through the full RustAPI request pipeline directly (via InvocationMode::InProcess).
Run it with:
cargo run -p rustapi-rs --example mcp_tools --features protocol-mcpThe example starts two listeners:
- HTTP API on
http://127.0.0.1:8080 - MCP endpoint on
http://127.0.0.1:9090(point your MCP client here)
You can also drive it manually with curl (see the comments at the top of the example file for ready-to-paste JSON-RPC commands).
See also the dedicated cookbook recipes for MCP in-process, the cargo rustapi mcp generate CLI (for any OpenAPI), and stdio transport.
For a more complete, standalone MCP example (with full project structure, ready-to-use Cargo project), see the rustapi-rs-examples repository (05-mcp-server example).
- Keep this file aligned with the actual
.rsfiles in this directory. - User-facing examples should import from
rustapi_rs::prelude::*unless the example is explicitly about internals. - New examples should be listed in this file when added under
examples/.