Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:APIJSON APIJSON Method Override

From Leeroopedia
Knowledge Sources
Domains API_Design, Request_Processing, Transaction_Management
Last Updated 2026-10-11 00:00 GMT

Overview

A directive-based mechanism that allows a single API request to execute multiple CRUD operations on different tables by overriding the HTTP method per-object within the request tree.

Description

Method Override in APIJSON is the ability to specify a different HTTP method for each table object in a single request. While the HTTP method (GET/POST/PUT/DELETE) sets the default operation for all tables, the @method directive can be placed inside any table object to override it:

  • Global: "@method": "PUT" at the request root overrides the HTTP method for all objects
  • Per-object: "@method": "POST" inside a specific table object overrides it for just that table

This enables the CRUD request method, where a single HTTP request can contain multiple operations (e.g., create a Comment, update a Moment's comment count, delete a notification) all within one transaction.

The pattern solves the problem of requiring multiple HTTP round trips for related operations. By allowing method overrides within a single request, all operations share one transaction, ensuring atomicity.

Usage

Use this principle when:

  • Multiple related operations need to be atomic (all succeed or all fail)
  • Reducing HTTP round trips for batch operations
  • The API needs to support complex workflows like "create X and update Y"

Theoretical Basis

# Abstract algorithm (NOT real implementation):
def resolve_method(global_method, request, key, value):
    # Check for per-object @method directive
    if isinstance(value, dict) and "@method" in value:
        return RequestMethod.parse(value["@method"])
    
    # Use global @method if set
    if "@method" in request:
        return RequestMethod.parse(request["@method"])
    
    # Fall back to HTTP method from URL
    return global_method

# In CRUD mode, each object in the tree can have a different method:
# {
#   "Comment": { "@method": "POST", "content": "Hello" },   # INSERT
#   "Moment": { "@method": "PUT", "commentCount+": 1 },    # UPDATE
#   "Notify": { "@method": "DELETE", "id@": "/Comment/id" } # DELETE
# }

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment