FORGEBOX Enterprise 🚀 - Take your ColdFusion (CFML) Development to Modern Times! Learn More...

REST APP Template

REST Template

This template gives you the base for building RESTFul web services with ColdBox. Check out the handlers folder to see how to leverage our base event handler component for RESTFul routing, consistency and marshalling.

In the models folder you will find our Universal REST Response object that can be leveraged as your base for building RESTFul services.

Implicit Methods

The base handler implements an around handler approach to provide consistency and the following actions:

  • onError - Fires whenever there is a runtime exception in any action
  • onInvalidHTTPMethod - Fires on invalid HTTP method access
  • onMissingAction - Fires on invalid missing actions on handlers

Utility Functions

We also give you some utility functions for RESTFul building:

  • routeNotFound - Can be used to fire of route not founds via 404
  • onExpectationFailed - Can be called when an expectation of a request fails, like invalid parameters/headers etc.
  • onAuthorizationFailure - Can be called to send a NOT Authorized status code and message.

HTTP Security

By default the base handlers leverages ColdBox method security via the this.allowedMethods structure:

this.allowedMethods = {
    "index"     : METHODS.GET,
    "get"       : METHODS.GET,
    "list"      : METHODS.GET,
    "update"    : METHODS.PUT & "," & METHODS.PATCH,
    "delete"    : METHODS.DELETE
};

HTTP Methods

The base handler contains a static construct called METHODS that implements basic HTTP Methods that you can use for messages and allowed methods.

METHODS = {
    "HEAD"      : "HEAD",
    "GET"       : "GET",
    "POST"      : "POST",
    "PATCH"     : "PATCH",
    "PUT"       : "PUT",
    "DELETE"    : "DELETE"
};

Status Codes

The base handler contains a static construct called STATUS that implements basic HTTP status codes you can use:

STATUS = {
    "CREATED"               : 201,
    "ACCEPTED"              : 202,
    "SUCCESS"               : 200,
    "NO_CONTENT"            : 204,
    "RESET"                 : 205,
    "PARTIAL_CONTENT"       : 206,
    "BAD_REQUEST"           : 400,
    "NOT_AUTHORIZED"        : 401,
    "NOT_FOUND"             : 404,
    "NOT_ALLOWED"           : 405,
    "NOT_ACCEPTABLE"        : 406,
    "TOO_MANY_REQUESTS"     : 429,
    "EXPECTATION_FAILED"    : 417,
    "INTERNAL_ERROR"        : 500,
    "NOT_IMPLEMENTED"       : 501
};

License

Apache License, Version 2.0.

Important Links

Source Code

  • https://github.com/coldbox-templates/rest

Quick Installation

Each application templates contains a box.json so it can leverage CommandBox for its dependencies.
Just go into each template directory and type:

box install

This will setup all the needed dependencies for each application template. You can then type:

box server start

And run the application.


###THE DAILY BREAD

"I am the way, and the truth, and the life; no one comes to the Father, but by me (JESUS)" Jn 14:1-12

Here are all the versions for this package. Please note that you can leverage CommandBox package versioning to install any package you like. Please refer to our managing package version guide for more information.

Version Created Last Update Published By Stable Download
2.18.0 May 10 2019 04:54 PM May 10 2019 04:54 PM Ortus Solutions (ortus)
2.17.0 Apr 30 2019 01:39 PM Apr 30 2019 01:39 PM Ortus Solutions (ortus)
2.16.0 Nov 06 2018 04:55 AM Nov 06 2018 04:55 AM Ortus Solutions (ortus)
2.15.0 Oct 23 2018 05:31 PM Oct 23 2018 05:31 PM Ortus Solutions (ortus)
2.14.0 Oct 01 2018 03:49 PM Oct 01 2018 03:49 PM Ortus Solutions (ortus)
2.13.0 Jul 18 2018 01:48 PM Jul 18 2018 01:48 PM Ortus Solutions (ortus)
2.12.0 Jul 02 2018 05:56 PM Jul 02 2018 05:56 PM Ortus Solutions (ortus)
2.11.0 Apr 27 2018 09:13 AM Apr 27 2018 09:13 AM Ortus Solutions (ortus)
2.10.0 Apr 25 2018 11:05 AM Apr 25 2018 11:05 AM Ortus Solutions (ortus)
2.9.0 Jan 22 2018 11:56 AM Jan 22 2018 11:56 AM Ortus Solutions (ortus)
2.8.0 Jan 16 2018 07:07 PM Jan 16 2018 07:07 PM Ortus Solutions (ortus)
2.7.0 Jan 16 2018 06:36 PM Jan 16 2018 06:36 PM Ortus Solutions (ortus)
2.6.0 Jan 12 2018 01:44 PM Jan 12 2018 01:44 PM Ortus Solutions (ortus)
2.5.0 Jan 12 2018 12:57 PM Jan 12 2018 12:57 PM Ortus Solutions (ortus)
2.4.0 Jan 08 2018 02:46 PM Jan 08 2018 02:46 PM Ortus Solutions (ortus)
2.3.0 Jul 05 2017 12:53 PM Jul 05 2017 12:53 PM Ortus Solutions (ortus)
2.2.0 Jun 19 2017 04:14 PM Jun 19 2017 04:14 PM Ortus Solutions (ortus)
2.1.0 Apr 04 2017 10:25 AM Apr 04 2017 10:25 AM Ortus Solutions (ortus)
2.0.0 Feb 23 2017 03:37 PM Feb 23 2017 03:37 PM Ortus Solutions (ortus)
1.4.0 Feb 09 2017 08:20 AM Feb 09 2017 08:20 AM Ortus Solutions (ortus)
1.3.0 Dec 09 2016 10:52 PM Dec 09 2016 10:52 PM Ortus Solutions (ortus)
1.2.0 Nov 02 2016 11:58 AM Nov 02 2016 11:58 AM Ortus Solutions (ortus)
1.1.0 Oct 05 2016 06:07 PM Oct 05 2016 06:07 PM Ortus Solutions (ortus)
1.0.0 Apr 07 2016 01:43 PM Jun 09 2016 05:18 PM Ortus Solutions (ortus)

 

No collaborators yet.
     
  • Apr 07 2016 01:43 PM
  • May 10 2019 04:54 PM
  • 985
  • 2699
  • 1254