mirror of
https://github.com/sasjs/core.git
synced 2026-01-11 02:50:06 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6fca73e7da | ||
|
|
880df4138c |
64
all.sas
64
all.sas
@@ -18499,6 +18499,58 @@ run;
|
|||||||
%inc &fref1;
|
%inc &fref1;
|
||||||
|
|
||||||
%mend mmx_spkexport;/**
|
%mend mmx_spkexport;/**
|
||||||
|
@file
|
||||||
|
@brief Sets the http headers in the SASjs/server response
|
||||||
|
@details For GET requests, SASjs server will use the file generated by this
|
||||||
|
macro for setting the appropriate http headers in the response.
|
||||||
|
|
||||||
|
It works by writing a file to the session directory, that is then ingested by
|
||||||
|
the server.
|
||||||
|
|
||||||
|
The location of this file is driven by the global variable
|
||||||
|
`sasjs_stpsrv_header_loc` which is made available in the autoexec.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
%mfs_httpheader(Content-type,application/csv)
|
||||||
|
|
||||||
|
@param [in] header_name Name of the http header to set
|
||||||
|
@param [in] header_value Value of the http header to set
|
||||||
|
|
||||||
|
<h4> Related Macros </h4>
|
||||||
|
@li mcf_stpsrv_header.sas
|
||||||
|
|
||||||
|
@version 9.3
|
||||||
|
@author Allan Bowe
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
%macro mfs_httpheader(header_name
|
||||||
|
,header_value
|
||||||
|
)/*/STORE SOURCE*/;
|
||||||
|
%local fref fid i;
|
||||||
|
|
||||||
|
%if %sysfunc(filename(fref,&sasjs_stpsrv_header_loc)) ne 0 %then %do;
|
||||||
|
%put &=fref &=sasjs_stpsrv_header_loc;
|
||||||
|
%put %str(ERR)OR: %sysfunc(sysmsg());
|
||||||
|
%return;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
%let fid=%sysfunc(fopen(&fref,A));
|
||||||
|
|
||||||
|
%if &fid=0 %then %do;
|
||||||
|
%put %str(ERR)OR: %sysfunc(sysmsg());
|
||||||
|
%return;
|
||||||
|
%end;
|
||||||
|
|
||||||
|
%let rc=%sysfunc(fput(&fid,%str(&header_name): %str(&header_value)));
|
||||||
|
%let rc=%sysfunc(fwrite(&fid));
|
||||||
|
|
||||||
|
%let rc=%sysfunc(fclose(&fid));
|
||||||
|
%let rc=%sysfunc(filename(&fref));
|
||||||
|
|
||||||
|
%mend mfs_httpheader;
|
||||||
|
/**
|
||||||
@file
|
@file
|
||||||
@brief Send data to/from @sasjs/server
|
@brief Send data to/from @sasjs/server
|
||||||
@details This macro should be added to the start of each web service,
|
@details This macro should be added to the start of each web service,
|
||||||
@@ -18533,8 +18585,9 @@ run;
|
|||||||
`,"$tablename":{"formats":{"col1":"$CHAR1"},"types":{"COL1":"C"}}`
|
`,"$tablename":{"formats":{"col1":"$CHAR1"},"types":{"COL1":"C"}}`
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mp_jsonout.sas
|
|
||||||
@li mf_getuser.sas
|
@li mf_getuser.sas
|
||||||
|
@li mp_jsonout.sas
|
||||||
|
@li mfs_httpheader.sas
|
||||||
|
|
||||||
<h4> Related Macros </h4>
|
<h4> Related Macros </h4>
|
||||||
@li mv_webout.sas
|
@li mv_webout.sas
|
||||||
@@ -18586,11 +18639,11 @@ run;
|
|||||||
/* fix encoding */
|
/* fix encoding */
|
||||||
OPTIONS NOBOMFILE;
|
OPTIONS NOBOMFILE;
|
||||||
|
|
||||||
|
/* set the header */
|
||||||
|
%mfs_httpheader(Content-type,application/json)
|
||||||
|
|
||||||
/* setup json */
|
/* setup json */
|
||||||
data _null_;file &fref encoding='utf-8' termstr=lf;
|
data _null_;file &fref encoding='utf-8' termstr=lf;
|
||||||
%if %str(&_debug) ge 131 %then %do;
|
|
||||||
put '>>weboutBEGIN<<';
|
|
||||||
%end;
|
|
||||||
put '{"SYSDATE" : "' "&SYSDATE" '"';
|
put '{"SYSDATE" : "' "&SYSDATE" '"';
|
||||||
put ',"SYSTIME" : "' "&SYSTIME" '"';
|
put ',"SYSTIME" : "' "&SYSTIME" '"';
|
||||||
run;
|
run;
|
||||||
@@ -18670,9 +18723,6 @@ run;
|
|||||||
memsize=quote(cats(memsize));
|
memsize=quote(cats(memsize));
|
||||||
put ',"MEMSIZE" : ' memsize;
|
put ',"MEMSIZE" : ' memsize;
|
||||||
put "}" @;
|
put "}" @;
|
||||||
%if %str(&_debug) ge 131 %then %do;
|
|
||||||
put '>>weboutEND<<';
|
|
||||||
%end;
|
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,9 @@
|
|||||||
`,"$tablename":{"formats":{"col1":"$CHAR1"},"types":{"COL1":"C"}}`
|
`,"$tablename":{"formats":{"col1":"$CHAR1"},"types":{"COL1":"C"}}`
|
||||||
|
|
||||||
<h4> SAS Macros </h4>
|
<h4> SAS Macros </h4>
|
||||||
@li mp_jsonout.sas
|
|
||||||
@li mf_getuser.sas
|
@li mf_getuser.sas
|
||||||
|
@li mp_jsonout.sas
|
||||||
|
@li mfs_httpheader.sas
|
||||||
|
|
||||||
<h4> Related Macros </h4>
|
<h4> Related Macros </h4>
|
||||||
@li mv_webout.sas
|
@li mv_webout.sas
|
||||||
@@ -86,11 +87,11 @@
|
|||||||
/* fix encoding */
|
/* fix encoding */
|
||||||
OPTIONS NOBOMFILE;
|
OPTIONS NOBOMFILE;
|
||||||
|
|
||||||
|
/* set the header */
|
||||||
|
%mfs_httpheader(Content-type,application/json)
|
||||||
|
|
||||||
/* setup json */
|
/* setup json */
|
||||||
data _null_;file &fref encoding='utf-8' termstr=lf;
|
data _null_;file &fref encoding='utf-8' termstr=lf;
|
||||||
%if %str(&_debug) ge 131 %then %do;
|
|
||||||
put '>>weboutBEGIN<<';
|
|
||||||
%end;
|
|
||||||
put '{"SYSDATE" : "' "&SYSDATE" '"';
|
put '{"SYSDATE" : "' "&SYSDATE" '"';
|
||||||
put ',"SYSTIME" : "' "&SYSTIME" '"';
|
put ',"SYSTIME" : "' "&SYSTIME" '"';
|
||||||
run;
|
run;
|
||||||
@@ -170,9 +171,6 @@
|
|||||||
memsize=quote(cats(memsize));
|
memsize=quote(cats(memsize));
|
||||||
put ',"MEMSIZE" : ' memsize;
|
put ',"MEMSIZE" : ' memsize;
|
||||||
put "}" @;
|
put "}" @;
|
||||||
%if %str(&_debug) ge 131 %then %do;
|
|
||||||
put '>>weboutEND<<';
|
|
||||||
%end;
|
|
||||||
run;
|
run;
|
||||||
%end;
|
%end;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user