返回顶部
r

rest-best-practices

Deep REST workflow—resource modeling, HTTP methods and safety, status codes, errors, pagination, caching, versioning, and idempotency. Use when designing HTTP APIs or reviewing controllers and gateways.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
110
下载量
0
收藏
概述
安装方式
版本历史

rest-best-practices

# REST Best Practices (Deep Workflow) REST is **HTTP semantics** used consistently: **resources** as nouns, **methods** with meaning, **predictable** errors, and **cacheable** reads where safe. ## When to Offer This Workflow **Trigger conditions:** - Designing public or partner HTTP APIs - Inconsistent verbs (GET with side effects); wrong status codes - CDN/caching surprises; client retry storms on POST **Initial offer:** Use **six stages**: (1) resource model, (2) methods & safety, (3) status & errors, (4) pagination & filtering, (5) caching & conditional requests, (6) versioning & evolution). Confirm JSON conventions and authentication model. --- ## Stage 1: Resource Model **Goal:** Clear collection vs item resources; relationships via sub-paths or hypermedia links (HATEOAS optional). **Exit condition:** Table or diagram of resources, identifiers, and canonical URLs. --- ## Stage 2: Methods & Safety **Goal:** GET/HEAD safe and idempotent; POST for creation or non-idempotent actions; PUT replaces; PATCH partial; DELETE removes. ### Anti-patterns - Non-idempotent GET; overloaded POST for everything without documented patterns --- ## Stage 3: Status & Errors **Goal:** Correct 4xx vs 5xx; consistent error body (e.g., RFC 7807 Problem Details) with stable `type` codes and optional `instance` for support. --- ## Stage 4: Pagination & Filtering **Goal:** Cursor pagination for large lists; document sort/filter query params; cap page sizes. --- ## Stage 5: Caching & Conditional Requests **Goal:** ETag/Last-Modified for cacheable GET; Cache-Control directives; validate with intermediaries (CDN) when used. --- ## Stage 6: Versioning & Evolution **Goal:** URL prefix or header versioning; deprecation policy; **Idempotency-Key** on POST when clients retry. --- ## Final Review Checklist - [ ] Resource model clear and consistent - [ ] HTTP methods match semantics; GET is safe - [ ] Status codes and errors consistent - [ ] Pagination and filtering documented - [ ] Caching headers where appropriate - [ ] Versioning and idempotency strategy ## Tips for Effective Guidance - Not everything is CRUD—model commands as sub-resources or task resources explicitly. - Pair with **openapi-spec** for contract-first workflows. ## Handling Deviations - Internal APIs still benefit from the same discipline—future consumers are often external.

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 rest-best-practices-1776030794 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 rest-best-practices-1776030794 技能

通过命令行安装

skillhub install rest-best-practices-1776030794

下载 Zip 包

⬇ 下载 rest-best-practices v1.0.0

文件大小: 1.96 KB | 发布时间: 2026-4-13 11:48

v1.0.0 最新 2026-4-13 11:48
REST Best Practices skill—initial release.

- Provides a deep, staged workflow for designing consistent, robust REST APIs.
- Covers resource modeling, HTTP methods and safety, status codes and errors, pagination, caching, versioning, and idempotency.
- Includes anti-patterns, review checklist, and practical tips for guidance and handling deviations.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部