Skip to content

Latest commit

 

History

History
118 lines (86 loc) · 3.66 KB

File metadata and controls

118 lines (86 loc) · 3.66 KB
outline
2
3
title Custom Parameters Annotation
titleTemplate NpgsqlRest
description Set custom key-value configuration for PostgreSQL REST API endpoints. Add metadata and custom settings to endpoints.
head
meta
name content
keywords
npgsqlrest custom parameters, endpoint metadata, key value config, custom endpoint settings, api custom config
meta
property content
og:title
NpgsqlRest Custom Parameters Annotation
meta
property content
og:description
Set custom key-value configuration and metadata for endpoints.
meta
property content
og:type
article

Custom Parameters

Set custom key-value configuration for the endpoint.

Syntax

@<key> = <value>

The @ prefix is optional - both @key = value and key = value work identically. Custom parameters with @ prefix are stored without the prefix (e.g., @my_param = value is stored as my_param).

Dynamic Parameter Values

Some parameters support dynamic values using the {param_name} format, where param_name references a function parameter. The value is resolved at runtime from the actual parameter value passed to the endpoint. The matching and substitution rules are shared across annotations — see Parameter Value Substitution.

Example

create function upload_file(_path text, _file text)
returns void
language sql
begin atomic;
  -- function body
end;

comment on function upload_file(text, text) is '
@upload for file_system
@file_system_path = {_path}
@file_system_file = {_file}
';

Equivalent as a SQL file endpoint (sql/upload-file.sql):

/*
HTTP POST
@upload for file_system
@file_system_path = {path}
@file_system_file = {file}
@param $1 path
@param $2 file
*/
select;

When called with {"_path": "/uploads/images", "_file": "photo.jpg"}, the file will be saved to /uploads/images/photo.jpg.

Built-in Parameters

Many annotations support the @key = value syntax. The following sections link to where each parameter group is documented.

General

These parameters are predefined annotations that also support the key = value syntax:

Upload

Upload handlers accept custom parameters to control file processing behavior per-endpoint:

Table Format

Per-endpoint control of HTML table and Excel spreadsheet rendering:

Server-Sent Events

SSE annotations that also support the key = value syntax:

TypeScript Client

Per-endpoint control of generated TypeScript client code:

Related