ColdBox Relax
Search…
Relax Programmatic DSL (Deprecated)

Relax Programmatic DSL

Deprecated as of Relax 2.3, but still available, the Relax DSL configuration object which is mixed into a simple Relax CFC Definition Object so you can use all the methods in this CFC to define RESTful web services. All functions can be concatenated to create a programmatic DSL. This DSL is exportable to OpenAPI formats.

Example Using the Forgebox API:

1
this.relax = {
2
// Service Title
3
title = "ForgeBox IO",
4
// Service Description
5
description = "This API powers ForgeBox",
6
// Service entry point, can be a single string or name value pairs to denote tiers
7
//entryPoint = "http://www.myapi.com",
8
entryPoint = {
9
"production" : "https://forgebox.io/api/v1",
10
"staging" : "http://forgebox.stg.ortussolutions.com/api/v1",
11
"development" : "http://localhost:9095/api/v1"
12
},
13
// Does it have extension detection via ColdBox
14
extensionDetection = true,
15
// Valid format extensions
16
validExtensions = "json",
17
// Does it throw exceptions when invalid extensions are detected
18
throwOnInvalidExtension = false
19
};
20
21
/************************************** GLOBAL PARAMS + HEADERS *********************************************/
22
23
// Global API Headers
24
globalHeader( name="x-app-token", description="The secret application token", required=true, type="string" );
25
26
/************************************** RESOURCES *********************************************/
27
28
// ECHO
29
resource( pattern="/echo", handler="Main", action="echo" )
30
.description( "Simple API echo command" )
31
.defaultFormat( "json" )
32
.methods( "GET" );
Copied!

Configuration

The relaxed service information. From here you will define the RESTful service endpoints, extension detection, valid formats, and more.

Arguments

Argument
Type
Required
Default
Description
title
any
Yes
---
The title of the RESTful service
description
any
Yes
---
The description of the RESTful service
entryPoint
any
Yes
---
A simple URL or a structure of entry points
extensionDetection
any
No
true
Will this API do extension detection
validExtensions
any
No
json,jsont,xml,html,htm,rss
The valid extensions to detect
The valid extensions to detec
any
No
false
Throw on invalid extensions or not

Global Headers

Add a global header to the relax definition

Arguments

Argument
Type
Required
Default
Description
name
any
Yes
---
The name of the header
description
any
No
The description of the header
required
any
No
false
Is the header required or not
default
any
No
The default value of this header
type
any
No
string
The type of the incoming header

Global Params

Add a global parameter to the relax definition

Arguments

Argument
Type
Required
Default
Description
name
any
Yes
---
The name of the parameter
description
any
No
The description of the parameter
required
any
No
false
Is the parameter required or not
default
any
No
The default value of this parameter
type
any
No
string
The type of the incoming parameter
Last modified 3yr ago