YTQRUTL ;SLC/KCM - RESTful API Utilities ; 1/25/2017
Source file <YTQRUTL.m>
| 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)  |