Try OpenEdge Now
skip to main content
New Information
OpenEdge Data Object Handler : Associate HTTP verbs with operation handlers
 

Associate HTTP verbs with operation handlers

HTTP verbs

For each custom service endpoint, you associate HTTP verbs with operation handlers. You can set up operation handlers for all HTTP verbs that are supported by the WEB transport. These include:
*GET
*PUT
*POST
*DELETE
*HEAD
*OPTIONS
*TRACE
*PATCH
Specify each verb that you want to use as a JSON object under the service endpoint in the mapping file. For example:
{
"services": {
"HelloService": {
"version": "1.0.0",
"operations": {
"/Greeting": {
"GET": {},
"PUT": {},
"POST": {}
},
"/Message": {
"GET": {},
"PUT": {}
},
"/": {
"GET": {}
}
}
}
}
}

Content types

Within each verb, define the MIME content type of the data that is returned by the endpoint. For example:
"/Greeting": {
"GET": {
"contentType": "application/json"
}
}
All MIME types (text/, image/, audio/, video/, application/, multipart/) are supported.

Status codes

In addition to the content type, define the status code that is returned by the endpoint. For example:
"/Greeting": {
"GET": {
"contentType": "application/json",
"statusCode": 200
}
}

Operation handlers

Next, map each HTTP verb with one operation handler. The DOH class provides the following operation handlers:
*void, that returns only a status code
*file, that returns the contents of a file
*entity, that invokes an ABL class or procedure
To map an HTTP verb with an operation handler, nest the operation handler under the verb as shown in this example:
"/Greeting": {
"GET": {
"contentType": "application/json",
"entity": {}
},
"PUT": {
"contentType": "application/json",
"entity": {}
}
}
"/Message": {
"GET": {
"contentType": "application/json",
"file": "filepath"
}
}
"/": {
"GET": {
"contentType": "application/json",
"void": null
}
}
The file and void operation handlers are simple key-value pairs whereas the entity handler is a JSON object. This is because the entity handler requires further information (such as the ABL class or procedure name, the method that will be invoked, etc).