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

REST APP Template

v2.29.0 Public

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 Actions
Current
2.29.0 Nov 18 2019 04:15 PM Nov 18 2019 04:15 PM
Version History
2.28.0 Oct 07 2019 08:15 AM Oct 07 2019 08:15 AM
2.27.0 Oct 04 2019 05:29 PM Oct 04 2019 05:29 PM
2.26.0 Sep 30 2019 02:27 PM Sep 30 2019 02:27 PM
2.25.0 Sep 26 2019 09:39 AM Sep 26 2019 09:39 AM
2.24.0 Sep 25 2019 02:55 PM Sep 25 2019 02:55 PM
2.23.0 Sep 25 2019 07:11 AM Sep 25 2019 07:11 AM
2.22.0 Sep 24 2019 05:44 PM Sep 24 2019 05:44 PM
2.21.0 Jul 18 2019 03:25 PM Jul 18 2019 03:25 PM
2.20.0 Jun 13 2019 12:57 PM Jun 13 2019 12:57 PM
2.19.0 May 25 2019 07:48 AM May 25 2019 07:48 AM
2.18.0 May 10 2019 04:54 PM May 10 2019 04:54 PM
2.17.0 Apr 30 2019 01:39 PM Apr 30 2019 01:39 PM
2.16.0 Nov 06 2018 04:55 AM Nov 06 2018 04:55 AM
2.15.0 Oct 23 2018 05:31 PM Oct 23 2018 05:31 PM
2.14.0 Oct 01 2018 03:49 PM Oct 01 2018 03:49 PM
2.13.0 Jul 18 2018 01:48 PM Jul 18 2018 01:48 PM
2.12.0 Jul 02 2018 05:56 PM Jul 02 2018 05:56 PM
2.11.0 Apr 27 2018 09:13 AM Apr 27 2018 09:13 AM
2.10.0 Apr 25 2018 11:05 AM Apr 25 2018 11:05 AM
2.9.0 Jan 22 2018 11:56 AM Jan 22 2018 11:56 AM
2.8.0 Jan 16 2018 07:07 PM Jan 16 2018 07:07 PM
2.7.0 Jan 16 2018 06:36 PM Jan 16 2018 06:36 PM
2.6.0 Jan 12 2018 01:44 PM Jan 12 2018 01:44 PM
2.5.0 Jan 12 2018 12:57 PM Jan 12 2018 12:57 PM
2.4.0 Jan 08 2018 02:46 PM Jan 08 2018 02:46 PM
2.3.0 Jul 05 2017 12:53 PM Jul 05 2017 12:53 PM
2.2.0 Jun 19 2017 04:14 PM Jun 19 2017 04:14 PM
2.1.0 Apr 04 2017 10:25 AM Apr 04 2017 10:25 AM
2.0.0 Feb 23 2017 03:37 PM Feb 23 2017 03:37 PM
1.4.0 Feb 09 2017 08:20 AM Feb 09 2017 08:20 AM
1.3.0 Dec 09 2016 10:52 PM Dec 09 2016 10:52 PM
1.2.0 Nov 02 2016 11:58 AM Nov 02 2016 11:58 AM
1.1.0 Oct 05 2016 06:07 PM Oct 05 2016 06:07 PM
1.0.0 Apr 07 2016 01:43 PM Jun 09 2016 05:18 PM

 

$ box install cbtemplate-rest

No collaborators yet.
     
  • Apr 07 2016 01:43 PM
  • Nov 18 2019 04:15 PM
  • 1,239
  • 4,463
  • 1,466