Javel2 - A fast and simple HTTP framework for
ah
This is the second version of javel, better, faster, prettier.
Install using BPM:
bpm -install ithirzty/javel2
- javel2 structure
- javel2_route structure
- javel2_stream structure
- HTML templating system
javel2_route A javel2 route.
base:
cpstring
Path to the root of your route in your file-system.path:
cpstring
Path to your route in the URL.cacheMaxAge:
int
If >= 0, the number of seconds that this route's request should be kept in cache (will not work if you set a custom handle).disableParsing:
bool
Will disable HTML parsing (will not work if you set a custom handle). This is set to false by default.handle:
function(javel2_route*, http_request*, http_response*)
Custom handle (useful for making API...).error:
function(javel2_route*, int, http_request*, http_response*)
Errors handle, first int argument is the http error code that must be sent to the client.
- HTML templating system.
The HTML templating system works with the following tag: <% type:name %>.
- <% function: myFunc %> Will call the
myFunc(req http_request*) cpstring
function. For this to work: myFunc should have a single argument that ishttp_request*
and return the HTML code ascpstring
. Additionaly, the function should be evaluable (by using the keyword#eval myFunc
). - <% stream: myFunc %> Will call the
myFunc(req http_request*, stream javel2_stream*)
function. The HTML code must be sent through the stream. This enables you to push HTML in real-time to the client. - <% file: path/myFile.html %> Will include the specified HTML file. The HTML file will be parsed.
- <% function: myFunc %> Will call the