Server-side REST in AdvPL
WSRESTFUL Ed619 ... END WSRESTFULDefines a constant-response REST route without data access.
Overview
WSRESTFUL declares methods and WSMETHOD handles requests/builds responses. The class name contributes to the URI under AppServer HTTP configuration. This subset uses a named GET without query parameters or request body and returns constant JSON. Authentication, TLS, tenant context and rights must be configured/tested outside this source; compiling it does not implement them. TDN warns classes compiled after HTTP_START may require a restart for publication; plan that operationally, not by restarting a server just to test this text. (Sources: refs. 1–3.)
Syntax
WSRESTFUL Ed619 ... END WSRESTFULCommented example
#Include "TOTVS.ch"
#Include "RESTFul.ch"
WSRESTFUL Ed619 DESCRIPTION "Editorial example status"
WSMETHOD GET STATUS DESCRIPTION "Editorial example status" ;
WSSYNTAX "/Ed619/status" PATH "/status" PRODUCES APPLICATION_JSON
END WSRESTFUL
WSMETHOD GET STATUS WSSERVICE Ed619
// Constant response: no business data or credentials.
Self:SetContentType("application/json")
Self:SetResponse('{"status":"ok"}')
Return .T.On an approved service the configured GET route returns {"status":"ok"}. It has not been compiled, registered or called on AppServer. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.
- For real data, validate format, bound pagination and check resource/branch permissions. Do not use NOTENANT or disable security as a shortcut.
- Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.