نمذجة الإجراءات (الدفع، الإلغاء)
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
model operations that are not plain CRUD.
الموضوعات المخطط لها
- Prefer to model the result as a resource:
POST /ordersto check out a cart. - Model state changes as a sub-resource or a state field:
POST /orders/7/cancellation, orPATCH /orders/7with a new status. - If it really is a command, a clear action sub-path is acceptable:
POST /orders/7/cancel. Be consistent. - Actions that change state use
POST(orPUT/PATCH), neverGET. - Document which state transitions are allowed; an invalid one returns
409.
تفاصيل المخطط المبدئي
عرض عملي
POST /carts/9/checkout -> 201, Location: /orders/42
POST /orders/42/cancel -> 200 (or 409 if already shipped)اختبر فهمك
Why not GET /orders/42/cancel?
أظهر الإجابة
GET must be safe; cancelling changes state.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.