Ian, This should be easy to do. You can create an HTTP header by hand by assigning it into request$httpheader.
So to return a 404: <@ASSIGN request$httpheader "HTTP/1.1 404 Not Found<@CRLF><@CRLF>"> You must end the header with two @CRLFs You can optionally use <@SETCOOKIES> and <@USERREFERENCECOOKIE> if you want to support cookies in your response The required http header components of Date and Content-Length will be added by the webserver so you don't have to calculate these values, although you can if you wish. Robert -----Original Message----- From: Ian Evans [mailto:[email protected]] Sent: Monday, January 12, 2015 6:42 PM To: [email protected] Subject: TeraScript-Talk: creating a restful api with terascript Hi All, Has anyone had any success creating a RESTful web api using Terascript? How did you do it? I'd like to be able to create/modify HTTP responses directly on the server side before returning. More specifically, so that I can use different HTTP response codes for different things (e.g., when information being requested via ajax doesn't exist, return HTTP 404.) I'm having trouble finding anything in the documentation relating to that, and from what I can tell, it's not readily available in TeraScribe either (though mine is admittedly old, 6.2.3.) The closest thing available is using <@THROWERROR> to invoke the error results, but then api clients still have to scan the response body, if provided, to see what the actual reason was, as the status of the HTTP response will be 200 or 500, I'm not sure which exactly. That solution is not really ideal. Any thoughts or suggestions on this? Thanks, -Ian ---------------------------------------- To unsubscribe from this list, please send an email to [email protected] with "unsubscribe terascript-talk" in the body. ---------------------------------------- To unsubscribe from this list, please send an email to [email protected] with "unsubscribe terascript-talk" in the body.
