YTQRUTL ;SLC/KCM - RESTful API Utilities ; 1/25/2017
Source file <YTQRUTL.m>
action | A | extended action | Ea | event driver | Ed | subscriber | Su | protocol | O | limited protocol | LP | run routine | RR | broker | B | edit | E | server | Se | P | screenman | SM | inquire | I |
Name | Comments | DBIA/ICR reference |
---|---|---|
HANDLE(URLTAG,HTTPREQ,HTTPRSP) | ; route REST request based on URL pattern
; URLTAG: tag^routine that begins mapping of path patterns to routines ; .HTTPREQ: GET/PUT/POST/DELETE request in HTTP form ; .HTTPRSP: response to caller in HTTP form |
|
XHANDLE | ; tag for exit if error
|
|
PARSHTTP(HTTPREQ,YTQRREQT,JSONBODY) | ; parse out header and body of HTTP HTTPREQ
|
|
PARSJSON(JSONBODY,YTQRTREE) | ; parse JSON request into M tree structure
|
|
MATCH(TAG,CALL,ARGS) | ; evaluate paths listed in TAG until match found (else 404)
; expects YTQRREQT to contain "path" and "method" nodes ; TAG contains the beginning tag where the paths are listed ; .ROUTINE contains TAG^ROUTINE, which will be called as TAG(.RESULTS,.ARGS) ; .ARGS will contain an array of any resolved path arguments |
|
QSPLIT(ARGS) | ; parses and decodes query fragments into ARGS
|
|
RESPONSE(YTQRRSLT,LOCATION) | ; build HTTPRSP based results or error
; from HANDLE, expects YTQRERRS (only defined if there were errors) ; YTQRERRS: positive number if there are errors to return ; YTQRRSLT: return value of the GET call ; LOCATION: return path of the POST call |
|
JSONRSP(ROOT,HTTPRSP) | ; encode response tree or error info as JSON
|
|
ADDHDR(DEST,SIZE,LOCATION) | ; add header values to response
; S HTTPRSP(.2)="Date: "_$$GMT |
|
BLDERRS(HTTPRSP) | ; Build response with error information
|
|
URLDEC(X,PATH) | ; Decode a URL-encoded string
; Q $ZCONVERT(X,"I","URL") ; uncomment for fastest performance on Cache |
|
URLENC(X) | ; Encode a string for use in a URL
; Q $ZCONVERT(X,"O","URL") ; uncomment for fastest performance on Cache ; =, &, %, +, non-printable ; {, } added JC 7-24-2012 |
|
LVSIZE(V) | ; return the size of a local variable
|
|
GVSIZE(ROOT) | ; return the size of a global variable (assumes WP format)
|
|
SETERROR(CODE,MSG) | ; set up error object
|
|
HTTPMSG(CODE) | ; return message for error code
|
|
ERRTXT() | ; return error message for non-HTTP RPC calls
|
|
ERRHDR() | ; return error header
|
|
TR2WP(SRC,DEST,DELIM) | ; Convert tree representation to FM WP
; SRC: glvn of source array (JSON node with wp text) ; DEST: glvn of destination array (will add [line,0] nodes) |
Name | Line Occurrences (* Changed, ! Killed) |
---|---|
^TMP("YTQ-JSON" | HANDLE+5!, RESPONSE+10 |
^TMP("YTQRERRS" | HANDLE+5!, BLDERRS+2, SETERROR+1*, SETERROR+2*, SETERROR+3*, SETERROR+4*, SETERROR+5*, SETERROR+6*, ERRTXT+3, ERRTXT+5 , ERRHDR+2, ERRHDR+3 |
Name | Line Occurrences |
---|---|
$$ERRHDR | ADDHDR+7 |
$$GVSIZE | RESPONSE+11 |
$$HTTPMSG | SETERROR+4 |
$$LVSIZE | RESPONSE+16, BLDERRS+3 |
$$URLDEC | MATCH+15, MATCH+16, QSPLIT+3 |
$$URLENC | ADDHDR+3 |
@( | HANDLE+12, HANDLE+13 |
ADDHDR | RESPONSE+11, RESPONSE+16, RESPONSE+18, RESPONSE+20, BLDERRS+3 |
BLDERRS | RESPONSE+6, RESPONSE+21 |
JSONRSP | RESPONSE+15, BLDERRS+2 |
MATCH | HANDLE+8 |
PARSHTTP | HANDLE+6 |
PARSJSON | HANDLE+7 |
QSPLIT | HANDLE+9 |
RESPONSE | XHANDLE+1 |
SETERROR | PARSHTTP+9, PARSHTTP+10, PARSJSON+3, MATCH+24, RESPONSE+12, RESPONSE+19, JSONRSP+4 |
XHANDLE | HANDLE+6, HANDLE+7, HANDLE+8 |
Name | Field # of Occurrence |
---|---|
^(0 | SETERROR+1 |
>> | Not killed explicitly |
* | Changed |
! | Killed |
~ | Newed |
Name | Field # of Occurrence |
---|---|
ARGS | MATCH~, MATCH+11!, QSPLIT~ |
ARGS( | MATCH+22*, QSPLIT+5* |
ARGUMENT | MATCH+6~, MATCH+20*, MATCH+22 |
ASC | URLDEC+3~, URLDEC+7*, URLDEC+8 |
CALL | HANDLE+4~, HANDLE+8, HANDLE+11, HANDLE+12, HANDLE+13, MATCH~, MATCH+23* |
CODE | URLENC+14*, URLENC+15, SETERROR~, SETERROR+3, SETERROR+4, HTTPMSG~, HTTPMSG+1, HTTPMSG+2, HTTPMSG+3, HTTPMSG+4 , HTTPMSG+5 |
DELIM | TR2WP~, TR2WP+5*, TR2WP+6, TR2WP+9, TR2WP+10, TR2WP+11 |
DEST | ADDHDR~, ADDHDR+3, ADDHDR+5, ADDHDR+6, ADDHDR+7, ADDHDR+8, TR2WP~, TR2WP+6, TR2WP+10, TR2WP+11 |
ERRORS | PARSJSON+1~, PARSJSON+3, JSONRSP+1~, JSONRSP+4 |
ERRORS(1 | PARSJSON+3, JSONRSP+4 |
FRAG | URLDEC+3~, URLDEC+7*, URLDEC+9 |
HTTPREQ | HANDLE~, HANDLE+6, PARSHTTP~ |
HTTPREQ( | PARSHTTP+7, PARSHTTP+8 |
HTTPREQ(1 | PARSHTTP+2, PARSHTTP+4, PARSHTTP+6 |
HTTPRSP | HANDLE~, RESPONSE+5!, RESPONSE+6, RESPONSE+10*, RESPONSE+11, RESPONSE+15, RESPONSE+16, RESPONSE+21, JSONRSP~, JSONRSP+2! , BLDERRS~, BLDERRS+1!, BLDERRS+2, BLDERRS+3 |
I | PARSHTTP+1~, PARSHTTP+7*, PARSHTTP+8*, MATCH+6~, MATCH+10*, QSPLIT+1~, QSPLIT+2*, QSPLIT+3, URLDEC+3~, URLDEC+5* , URLDEC+6, URLDEC+7, URLENC+4~, URLENC+5*, URLENC+6*, URLENC+7*, URLENC+8*, URLENC+9*, URLENC+10*, URLENC+13* , URLENC+14, URLENC+15, LVSIZE+2~, LVSIZE+5*, GVSIZE+2~, GVSIZE+5*, ERRTXT+1~, ERRTXT+3*, ERRTXT+5, TR2WP+4~ , TR2WP+7*, TR2WP+8 |
J | PARSHTTP+1~, PARSHTTP+8*, MATCH+6~, MATCH+14*, MATCH+15, MATCH+16, TR2WP+4~, TR2WP+6*, TR2WP+9*, TR2WP+10 , TR2WP+11 |
JSONBODY | HANDLE+4~, HANDLE+6, HANDLE+7, PARSHTTP~, PARSJSON~ |
JSONBODY( | PARSHTTP+8* |
LAST | URLENC+4~, URLENC+12*, URLENC+15*, URLENC+16 |
LN | TR2WP+4~, TR2WP+5*, TR2WP+6*, TR2WP+10, TR2WP+11* |
LOCATION | HANDLE+4~, XHANDLE+1, RESPONSE~, RESPONSE+19, RESPONSE+20, ADDHDR~, ADDHDR+2, ADDHDR+3 |
MSG | SETERROR~, SETERROR+6 |
NAME | QSPLIT+1~, QSPLIT+4*, QSPLIT+5 |
OUT | URLDEC+3~, URLDEC+6*, URLDEC+8*, URLDEC+9*, URLDEC+10 |
PATH | MATCH+6~, MATCH+7*, MATCH+9*, MATCH+13, MATCH+14, MATCH+15, URLDEC~, URLDEC+4 |
PATHFND | MATCH+6~, MATCH+7*, MATCH+10, MATCH+23*, MATCH+24 |
PATTERN | MATCH+6~, MATCH+11*, MATCH+13, MATCH+16 |
ROOT | JSONRSP~, JSONRSP+3, GVSIZE~, GVSIZE+1, GVSIZE+4, GVSIZE+5 |
RTN | MATCH+6~, MATCH+8* |
SEGPATH | MATCH+6~, MATCH+15*, MATCH+17, MATCH+21, MATCH+22 |
SEGPTRN | MATCH+6~, MATCH+16*, MATCH+17, MATCH+19*, MATCH+20 |
SEGSOK | MATCH+6~, MATCH+14*, MATCH+17*, MATCH+21*, MATCH+23 |
SIZE | ADDHDR~, ADDHDR+4, ADDHDR+6, LVSIZE+2~, LVSIZE+3*, LVSIZE+4*, LVSIZE+5*, LVSIZE+6, GVSIZE+2~, GVSIZE+3* , GVSIZE+4*, GVSIZE+5*, GVSIZE+6 |
SRC | TR2WP~, TR2WP+5, TR2WP+7, TR2WP+8 |
TAG | MATCH~, MATCH+8* |
TEST | MATCH+6~, MATCH+20*, MATCH+21 |
URLTAG | HANDLE~, HANDLE+8 |
V | LVSIZE~, LVSIZE+1, LVSIZE+4, LVSIZE+5 |
V( | LVSIZE+5 |
VALUE | QSPLIT+1~, QSPLIT+4*, QSPLIT+5 |
X | PARSHTTP+1~, PARSHTTP+7*, MATCH+6~, MATCH+10*, MATCH+11, MATCH+12, MATCH+23, QSPLIT+1~, QSPLIT+3*, QSPLIT+4 , URLDEC~, URLDEC+4*, URLDEC+5, URLDEC+6, URLDEC+7, URLENC~, URLENC+5, URLENC+6*, URLENC+7*, URLENC+8* , URLENC+9*, URLENC+10*, ERRTXT+1~, ERRTXT+2*, ERRTXT+4*, ERRTXT+5*, ERRTXT+6, ERRHDR+1~, ERRHDR+2*, ERRHDR+3* , ERRHDR+4*, ERRHDR+5, TR2WP+4~, TR2WP+5*, TR2WP+6, TR2WP+8*, TR2WP+9, TR2WP+10, TR2WP+11 |
Y | URLENC+4~, URLENC+5*, URLENC+6*, URLENC+7*, URLENC+8*, URLENC+9*, URLENC+10*, URLENC+11*, URLENC+13, URLENC+14 , URLENC+15, URLENC+16 |
YTQRARGS | HANDLE+4~, HANDLE+8, HANDLE+9 |
YTQRERRS | HANDLE+4~, HANDLE+6, HANDLE+7, HANDLE+8, RESPONSE+6, RESPONSE+21, ADDHDR+7, SETERROR+7* |
YTQRREQT | HANDLE+4~, HANDLE+6, PARSHTTP~ |
YTQRREQT("header" | PARSHTTP+7* |
YTQRREQT("method" | HANDLE+11, HANDLE+12, HANDLE+13, PARSHTTP+2*, PARSHTTP+9, MATCH+12, RESPONSE+18, SETERROR+5 |
YTQRREQT("path" | PARSHTTP+4*, PARSHTTP+10, MATCH+7, SETERROR+5 |
YTQRREQT("query" | PARSHTTP+6*, QSPLIT+2, QSPLIT+3, SETERROR+5 |
YTQRRSLT | HANDLE+4~, XHANDLE+1, RESPONSE~, RESPONSE+7, RESPONSE+8 |
YTQRTREE | HANDLE+4~, HANDLE+7, PARSJSON~ |
Z | URLENC+4~, URLENC+12*, URLENC+15*, URLENC+16*, URLENC+17 |
Name | Field # of Occurrence |
---|---|
$T(@(7) | MATCH+10 |