myfy web routing with FastAPI-like decorators. Use when working with WebModule, @route decorators, path parameters, query parameters, request bodies, AuthModule for authentication, RateLimitModule for rate limiting, or error handling.
View on GitHubSelect agents to install to:
npx add-skill https://github.com/psincraian/myfy/blob/main/plugins/claude-code/skills/routing-api/SKILL.md -a claude-code --skill routing-apiInstallation paths:
.claude/skills/routing-api/# Web Routing in myfy
myfy provides FastAPI-like routing with full DI integration.
## Route Decorators
```python
from myfy.web import route
@route.get("/path")
async def handler() -> dict:
return {"message": "hello"}
@route.post("/path", status_code=201)
async def create() -> dict:
return {"created": True}
@route.put("/path/{id}")
async def update(id: int) -> dict:
return {"updated": id}
@route.delete("/path/{id}", status_code=204)
async def delete(id: int) -> None:
pass
@route.patch("/path/{id}")
async def partial_update(id: int) -> dict:
return {"patched": id}
```
## Path Parameters
Extract from URL template using `{param}`:
```python
@route.get("/users/{user_id}/posts/{post_id}")
async def get_post(user_id: int, post_id: int) -> dict:
return {"user": user_id, "post": post_id}
```
Path parameters are:
- Automatically type-converted based on annotation
- Must match function parameter names exactly
- Must be valid Python identifiers
## Query Parameters
Use `Query` for explicit query parameters:
```python
from myfy.web import Query
@route.get("/search")
async def search(
q: str = Query(default=""), # With default value
limit: int = Query(default=10), # Integer query param
page: int = Query(alias="p"), # Aliased (?p=1 in URL)
) -> dict:
return {"query": q, "limit": limit, "page": page}
```
## Request Body
Use Pydantic models or dataclasses for request bodies:
```python
from pydantic import BaseModel
class UserCreate(BaseModel):
email: str
name: str
@route.post("/users", status_code=201)
async def create_user(body: UserCreate, session: AsyncSession) -> dict:
user = User(**body.model_dump())
session.add(user)
await session.commit()
return {"id": user.id}
```
Request bodies are automatically:
- Parsed from JSON
- Validated by Pydantic
- Type-checked at runtime
## Parameter Classification
Parameters are classified in this order:
1. **Path parameters** - Names m