Skip to content

HTTP Methods

Thomas Pollet edited this page Mar 8, 2026 · 4 revisions

HTTP Methods and Hooks

Restricting allowed methods with http_methods

You can restrict the CRUD methods SAFRS exposes with http_methods.

Examples:

http_methods = {"GET", "POST"}

In the FastAPI adapter, http_methods affects both runtime behavior and generated OpenAPI operations.

Hook overrides

Common hook points include:

  • _s_post
  • _s_patch

Example:

Read-only models

You can create read-only or partially writable models by restricting http_methods rather than overriding every individual operation.

Relationship interaction

Relationship mutation behavior also depends on whether the parent model remains patchable. This is especially visible in the FastAPI adapter.

FastAPI note

The FastAPI adapter explicitly reads Model.http_methods, documents the allowed operations, and gates routes accordingly.

Clone this wiki locally