relax

Class RelaxDSL

lucee.Component
    extended by relax.RelaxDSL

Copyright Ortus Solutions, Corp, All rights reserved www.ortussolutions.com --- Relax offers you a nice programmatic DSL to define RESTFul web services. All functions defined in this DSL can be concatenated with each other to create expressive and human readable representations of your API Definitions.

Class Attributes:
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
    Constructor Summary
    init()
          Constructor.
    Method Summary
    any appendData(struct args, string dataKey)
         Append Data elements.
    any appendResponse(struct args, string dataKey)
         Append a response to a resource.
    any defaultFormat(string format)
         Define a default return format for a resource.
    any defaultMethod(string method)
         Define a default HTTP method for a resource.
    any description(string description)
         Add a description to a resource.
    any globalHeader(string name, [string description=''], [boolean required='false'], [string defaultValue=''], [string type='string'])
         Add a global header to the relax definition.
    any globalParam(string name, [string description=''], [boolean required='false'], [string defaultValue=''], [string type='string'])
         Add a global parameter to the relax definition.
    any header(string name, [string description=''], [boolean required='false'], [string defaultValue=''], [string type='string'])
         Add a header to a resource.
    any methods(any methods)
         Add valid HTTP methods to a resource.
    any param(string name, [string description=''], [boolean required='false'], [string defaultValue=''], [string type='string'])
         Add a parameter to a resource.
    any placeholder(string name, [string description=''], [boolean required='false'], [string defaultValue=''], [string type='string'])
         Add a placeholder to a resource.
    any resource(string pattern, [string handler], [any action], [string defaultMethod='GET'])
         Add a new resource to the API definition, you can then concatenate more methods to the same resource: methods(),description(),header(),parameter(),placeholder(),schema(),sample().
    any sample(string format, [string description=''], [string body=''])
         Append a sample to a resource.
    any schema(string format, [string description=''], [string body=''])
         Append a schema to a resource.
    any service(string title, string description, any entryPoint, [boolean extensionDetection='false'], [string validExtensions='json,jsont,xml,html,htm,rss'], [boolean throwOnInvalidExtensions='false'])
         The relaxed service information.
    any setHeaders(array headers)
         Set all the required headers of a resource.
    any setParams(array params)
         Set all the required parameters of a resource.
    any setPlaceHolders(array placeholders)
         Set all the required placeholders of a resource.
    any verifyResourcePivot()
         Verify if the resource pivot exists.
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init()

    Constructor


    Method Detail

    appendData

    public any appendData(struct args, string dataKey)

    Append Data elements

    Parameters:
    args - The incoming data arguments
    dataKey - The key to append it to
    Returns:
    RelaxDSL

    appendResponse

    public any appendResponse(struct args, string dataKey)

    Append a response to a resource

    Parameters:
    args - The data arguments
    dataKey - The key to add it to
    Returns:
    RelaxDSL

    defaultFormat

    public any defaultFormat(string format)

    Define a default return format for a resource

    Parameters:
    format - The format. Ex: json, xml, html
    Returns:
    RelaxDSL

    defaultMethod

    public any defaultMethod(string method)

    Define a default HTTP method for a resource

    Parameters:
    method - The HTTP method that will be the default
    Returns:
    RelaxDSL

    description

    public any description(string description)

    Add a description to a resource

    Parameters:
    description - The long description of a resource
    Returns:
    RelaxDSL

    globalHeader

    public any globalHeader(string name, [string description=''], [boolean required='false'], [string defaultValue=''], [string type='string'])

    Add a global header to the relax definition

    Parameters:
    name - The name of the header
    description - The description of the header
    required - Is the header required or not
    defaultValue - The default value of this header
    type - The type of the incoming header
    Returns:
    RelaxDSL

    globalParam

    public any globalParam(string name, [string description=''], [boolean required='false'], [string defaultValue=''], [string type='string'])

    Add a global parameter to the relax definition

    Parameters:
    name - The name of the parameter
    description - The description of the parameter
    required - Is the parameter required or not
    defaultValue - The default value of this parameter
    type - The type of the incoming parameter
    Returns:
    RelaxDSL

    header

    public any header(string name, [string description=''], [boolean required='false'], [string defaultValue=''], [string type='string'])

    Add a header to a resource

    Parameters:
    name - The name of the header
    description - The description of the header
    required - Is the header required or not
    defaultValue - The default value of this header
    type - The type of the incoming header
    Returns:
    RelaxDSL

    methods

    public any methods(any methods)

    Add valid HTTP methods to a resource

    Parameters:
    methods - A list of HTTP methods a resource allows
    Returns:
    RelaxDSL

    param

    public any param(string name, [string description=''], [boolean required='false'], [string defaultValue=''], [string type='string'])

    Add a parameter to a resource

    Parameters:
    name - The name of the parameter
    description - The description of the parameter
    required - Is the parameter required or not
    defaultValue - The default value of this parameter
    type - The type of the incoming parameter
    Returns:
    RelaxDSL

    placeholder

    public any placeholder(string name, [string description=''], [boolean required='false'], [string defaultValue=''], [string type='string'])

    Add a placeholder to a resource

    Parameters:
    name - The name of the placeholder
    description - The description of the placeholder
    required - Is the placeholder required or not
    defaultValue - The default value of this placeholder
    type - The type of the incoming placeholder
    Returns:
    RelaxDSL

    resource

    public any resource(string pattern, [string handler], [any action], [string defaultMethod='GET'])

    Add a new resource to the API definition, you can then concatenate more methods to the same resource: methods(),description(),header(),parameter(),placeholder(),schema(),sample()

    Parameters:
    pattern - The SES pattern to register for the resource
    handler - The handler this pattern directs to
    action - The action this pattern directs to, it can be simple or a complex HTTP-Action struct: { "get" : "list", "delete", "doRemove" }
    defaultMethod
    Returns:
    RelaxDSL

    sample

    public any sample(string format, [string description=''], [string body=''])

    Append a sample to a resource

    Parameters:
    format - The format of the sample
    description - The description of the sample
    body - The body contents of the sample
    Returns:
    RelaxDSL

    schema

    public any schema(string format, [string description=''], [string body=''])

    Append a schema to a resource

    Parameters:
    format - The format of the schema
    description - The description of the schema
    body - The body contents of the schema
    Returns:
    RelaxDSL

    service

    public any service(string title, string description, any entryPoint, [boolean extensionDetection='false'], [string validExtensions='json,jsont,xml,html,htm,rss'], [boolean throwOnInvalidExtensions='false'])

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

    Parameters:
    title - The title of the RESTful service
    description - The description of the RESTful service
    entryPoint - A simple URL or a structure of entry points for different tiers: { dev="http://localhost/api", prd="http://www.mysite.com/api" }
    extensionDetection - Will this API do extension detection
    validExtensions - The valid extensions to detect
    throwOnInvalidExtensions - Throw on invalid extensions or not
    Returns:
    RelaxDSL

    setHeaders

    public any setHeaders(array headers)

    Set all the required headers of a resource

    Parameters:
    headers - Set the headers of a resource
    Returns:
    RelaxDSL

    setParams

    public any setParams(array params)

    Set all the required parameters of a resource

    Parameters:
    params - Set the parameters of a resource
    Returns:
    RelaxDSL

    setPlaceHolders

    public any setPlaceHolders(array placeholders)

    Set all the required placeholders of a resource

    Parameters:
    placeholders - Set the placeholders of a resource
    Returns:
    RelaxDSL

    verifyResourcePivot

    public any verifyResourcePivot()

    Verify if the resource pivot exists