Constants
New feature
Since 6.10.15
Purpose¶
A DSL that exposes commons constants from Platform 6.
Methods¶
Binding name: p6.const
mime¶
Provides access to common MIME types.
Syntax
string p6.const.mime.[type]
Available types:
JSON→application/jsonXML→application/xmlCSV→text/csvPDF→application/pdfXLSX→application/vnd.openxmlformats-officedocument.spreadsheetml.sheetXLS→application/vnd.ms-excelZIP→application/zipHTML→text/htmlTEXT→text/plainOCTET→application/octet-stream
Example
rest("/apis/sample")
.post("/data")
.consumes(p6.const.mime.JSON)
.produces(p6.const.mime.JSON)
.to("p6cmb://scripts?platform6.request.action=execute&id=simpleScript")
.routeId("RestCall")
service request¶
Provides access to common service request constants.
Syntax
string p6.const.service.request.[type]
Available types:
USER→platform6.request.userACTION→platform6.request.actionCOMMON_ACTION→platform6.request.common.action
Example
final def cm = [headers: [
(p6.const.service.request.ACTION) : 'status'
]]
p6.service.request('platform6.scripts', cm, {
cmr, e ->
println cmr
if( null != e) throw e
})
service response¶
Provides access to common service response constants.
Syntax
string p6.const.service.response.[type]
Available types:
STATUS→platform6.response.statusVALUE→platform6.response.valueEXCEPTION→platform6.response.exceptionEXCEPTION_MSG→platform6.response.exception.messageUNCAUGHT_EXCEPTION→platform6.response.uncaught.exception
Example
if (p6.pipeline.get(p6.const.service.response.STATUS) == 'ERROR') {
p6.log.error 'Service error: ' + p6.pipeline.get(p6.const.service.response.EXCEPTION_MSG)
} else {
p6.log.info 'Service OK: ' + p6.pipeline.get(p6.const.service.response.VALUE)
}