*api / n-api
*api is the general HTTP gateway directive. It supports GET-style loading, non-GET JSON requests, and file-input uploads.
- Non-clickable elements auto-run once.
- Button-like elements run on click.
<input type="file">runs on file selection.- Non-GET JSON requests send a Sercrod request envelope.
*responsemaps parsed responses into host data.
<button
type="button"
*api="/api/save"
method="POST"
body="form"
*params="{ source: 'settings' }"
*dry-run
*response="'result'">
Preview save
</button>
GET and body rules
GET requests do not send a JSON body. If *dry-run or non-empty *params is used with GET, Sercrod warns because those markers need a request body.
File input upload
<input
type="file"
name="avatar"
*api="/api/avatar"
*params="{ kind: 'avatar' }"
*response="'upload_result'">
For file inputs, Sercrod sends FormData. When *params or *dry-run is present, it appends JSON fields named sercrod, data, and params.
Response placement
Every successful response is mirrored to $response. Without *response, normal host data is not changed.
*into="user" is accepted as a compatibility alias for *response="'user'". When both are present, *response wins and Sercrod warns.