Skip to main content

Module standards

Module standards 

Source
Expand description

REST API standards helpers per .spec/sot/rest-api-standards.sot.md:

  • P-3: RFC 8288 Link pagination (page/per_page default 30, max 100) + X-Total-Count.
  • P-4: Strong ETag ("sha256-..."), If-None-Match (304), If-Match (412/428).
  • P-5 & O-10: IETF RateLimit-Policy / RateLimit + X-RateLimit-* + global limiter + quotas.

Structs§

PageParams
RateLimitDecision

Constants§

DEFAULT_API_RATE_LIMIT_PER_MIN
DEFAULT_MAX_BODY_BYTES
DEFAULT_PER_PAGE
MAX_PER_PAGE

Functions§

apply_etag_and_conditional_get
Apply strong ETag and If-None-Match (304 Not Modified) conditional GET handling.
attach_pagination_headers
Attach X-Total-Count and optional RFC 8288 Link pagination headers to a response.
attach_rate_limit_headers
Attach both IETF draft RateLimit-Policy/RateLimit and GitHub-compat X-RateLimit-* headers.
check_api_rate_limit
Evaluate the per-client-IP 60-second fixed-window API rate limiter (P-5 / O-10). Setting ARKS_API_RATE_LIMIT_PER_MIN=0 disables enforcement while still reporting unlimited.
check_api_rate_limit_with_cap
check_body_quota
Check request body size against ARKS_MAX_BODY_BYTES (default 64 MiB -> 413 Payload Too Large).
check_if_match
Verify If-Match precondition on optimistic-concurrency mutations (RFC 9110 §13.1.1). Returns 412 Precondition Failed on mismatch, or 428 Precondition Required when required is true and header is absent.
check_storage_quota
Check directory byte usage against an optional quota (507 Insufficient Storage).
compute_etag
Compute a strong quoted SHA-256 ETag ("sha256-<16-byte-hex>").
configured_api_rate_limit
format_link_header
Format an RFC 8288 Link header (rel="next", rel="prev", rel="first", rel="last").
paginate_slice
Slice a collection for (page, per_page) and return (items, total, Link header).
rate_limit_exceeded_response
Build a 429 Too Many Requests RFC 9457 response with Retry-After and rate-limit headers.