# Fastapi API Example Fastapi Middleware

> Use when working with FastAPI — middleware, HTTPException, error handling, logging

- Skill: `liaosw97/fastapi-api-example-fastapi-middleware` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add liaosw97/fastapi-api-example-fastapi-middleware`
- Raw SKILL.md: https://api.skillmd.com/api/skills/liaosw97/fastapi-api-example-fastapi-middleware/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- Author: liaosw97 (https://skillmd.com/u/liaosw97)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/liaosw97/fastapi-api-example-fastapi-middleware

---


- 对预期错误使用 HTTPException，并将其建模为特定的 HTTP 响应。
- 使用中间件处理意外错误、日志记录和错误监控。
- 使用 Pydantic 的 BaseModel 实现一致的输入/输出验证和响应模式。

