%CSP.REST
class %CSP.REST extends %CSP.Page
Applications wishing to support REST should subclass this class, implement the methods to be called and define a UrlMap XDATA block which maps Urls and request Method (DELETE/GET/POST/PUT) to those methods Users define a csp web application which will be serviced by their custom subclass. To achieve this,in the management portal set the 'Dispatch Class' to the name of the custom subclass of THIS class. See the csp/samples/docserver web application and the corresponding REST.DocServer sample in the SAMPLES namespaceMethod Inventory
- AcceptsContentType()
- AccessCheck()
- DispatchMap()
- DispatchRequest()
- Error()
- Http403()
- Http404()
- Http405()
- Http500()
- Login()
- OnHandleCorsRequest()
- OnHandleOptionsRequest()
- OnPreDispatch()
- Page()
- ReportHttpStatusCode()
- ResolveTarget()
- SetResponseHeaderIfEmpty()
- StatusToJSON()
- StatusToProxyObject()
- SupportedVerbs()
Parameters
parameter CONTENTTYPEJSON = application/json;
parameter CONTENTTYPETEXT = text/plain;
parameter HTTP200OK = 200 OK;
parameter HTTP201CREATED = 201 Created;
parameter HTTP202ACCEPTED = 202 Accepted;
parameter HTTP204NOCONTENT = 204 No Content;
parameter HTTP304NOTMODIFIED = 304 Not Modified;
parameter HTTP400BADREQUEST = 400 Bad Request;
parameter HTTP401UNAUTHORIZED = 401 Unauthorized;
parameter HTTP403FORBIDDEN = 403 Forbidden;
parameter HTTP404NOTFOUND = 404 Not Found;
parameter HTTP405METHODNOTALLOWED = 405 Method Not Allowed;
parameter HTTP406NOTACCEPTABLE = 406 Not Acceptable;
parameter HTTP409CONFLICT = 409 Conflict;
parameter HTTP415UNSUPPORTEDMEDIATYPE = 415 Unsupported Media Type;
parameter HTTP423LOCKED = 423 Locked;
parameter HTTP500INTERNALSERVERERROR = 500 Internal Server Error;
parameter HandleCorsRequest;
This parameter influences the CORS support. The default is an empty string meaning 'not specified'.
If set to true (1) then CORS processing is ON. If set to false (0) then CORS processing is OFF.
If left unset "" then the decision to process CORS is delegated to the setting on the URL map route.
parameter UseSession = 0;
This parameter controls the CSP session support. By default the CSP session will be
ended after each request in accordance with the spirit of REST. However this CAN be
overridden by the user. To use a session, it's necessary to manage the CSPSESSION cookie.
Browsers do this automatically but command line tools such as CURL require the setting of
options.
Note that if you choose to use a session then this will use a CSP license until the session is ended or expires and the grace period has been satisfied. If you use the default of no session then this will be the same behavior as SOAP requests of holding a license for ten seconds.
Methods
This method tests the HTTP_ACCEPT header and returns true if
the passed content type is acceptable
This method performs a basic access check. You can override this to add additional checks
This generator creates the DispatchMap Method used to dispatch the Url and Method to the associated target method
classmethod DispatchRequest(pUrl As %String, pMethod As %String, pForwarded As %Boolean = 0) as %Status
Dispatch a REST request according to URL and Method
Called for a REST page in the event of an error being trapped by CSP server
Issue an '403' error (Deprecated, use ..ReportHttpStatusCode)
Issue an '404' error (Deprecated, use ..ReportHttpStatusCode)
Issue an '405' error ( user can override)
classmethod Http500(pE As %Exception.AbstractException) as %Status
Issue an '500' error and give some indication as to what occurred
Called for a REST page in the event of a login being required
This is the CORS request handler. User should override this method in their subclass
if they don't want the default behavior
This methods provides handling of the options request.
Note carefully: If authentication is required then this method will be
called before login and as such will have only limited privileges
classmethod OnPreDispatch(pUrl As %String, pMethod As %String, ByRef pContinue As %Boolean) as %Status
This method Gets called prior to dispatch of the request. Put any common code here
that you want to be executed for EVERY request. If pContinue is set to 0, the
request will NOT be dispatched according to the UrlMap. If this case it's the
responsibility of the user to return a response.
This method matches matches the request and method and calls the dispatcher
Issue an 'Http' error
classmethod ResolveTarget(pOriginalUrl As %String, Output pTargetUrl As %String = "", Output pTargetClass As %String = "") as %Status
This resolves the target class and url according to the forwarding rules
This utility method sets a response header only if it currently does not have a value
final classmethod StatusToJSON(pSC As %Status, ByRef pJSON As %DynamicObject) as %Status
Render a %Status as JSON (in the form of an array of objects representing each status value).
final classmethod StatusToProxyObject(pSC As %Status, ByRef pJSON As %ZEN.proxyObject) as %Status
Render a %Status as JSON (in the form of an array of objects representing each status value).
This generator creates the SupportedVerbs Method used to determine supported verbs for return via 405 HTTP Status
Inherited Members
Inherited Methods
- %ClassIsLatestVersion()
- %ClassName()
- %DispatchClassMethod()
- %DispatchGetModified()
- %DispatchGetProperty()
- %DispatchMethod()
- %DispatchSetModified()
- %DispatchSetMultidimProperty()
- %DispatchSetProperty()
- %Extends()
- %GetParameter()
- %IsA()
- %New()
- %OriginalNamespace()
- %PackageName()
- %SetModified()
- ConvertParameter()
- Decrypt()
- Encrypt()
- EscapeHTML()
- EscapeURL()
- HyperEventCall()
- HyperEventHead()
- Include()
- InsertHiddenField()
- InsertHiddenFields()
- IsPrivate()
- Link()
- OnHTTPHeader()
- OnPage()
- OnPageError()
- OnPostHTTP()
- OnPostHyperEvent()
- OnPreHTTP()
- OnPreHyperEvent()
- QuoteJS()
- RewriteURL()
- ShowError()
- StartTimer()
- StopTimer()
- ThrowError()
- UnescapeHTML()
- UnescapeURL()