Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sabinadams/coldbox-rest
Coldbox RESTful API Example
https://github.com/sabinadams/coldbox-rest
Last synced: 23 days ago
JSON representation
Coldbox RESTful API Example
- Host: GitHub
- URL: https://github.com/sabinadams/coldbox-rest
- Owner: sabinadams
- Created: 2018-05-03T20:32:55.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T20:26:40.000Z (11 months ago)
- Last Synced: 2024-10-09T22:58:50.931Z (about 1 month ago)
- Language: ColdFusion
- Size: 55.7 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# 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](http://www.ortussolutions.com/products/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