The first line of each route script is checked for a “directive”. These are special comments that let you override the way a route is handled internally.
These are the directives that currently exist:
# sse
- this route will be used for Server-Sent Events (example)# allow-uploads
- this route will allow file uploads via a multipart encoded form. (example)# headers
- this route will be responsible for writing its own headers section, in addition to the response body. (example)The following variables are available in all route handlers:
REQUEST_METHOD
- the HTTP verb usedREQUEST_PATH
- the relative path of the requestREQUEST_QUERY
- the raw (unparsed) query stringThe framework will automatically parse the request and populate the following associative arrays:
HTTP_HEADERS
- The parsed request headersQUERY_PARAMS
- The parsed query parameter stringFORM_DATA
- The parsed form data (if applicable)PATH_VARS
- The parsed variable names for dynamic and catch-all routesCOOKIES
- The parsed cookies from the request headersThe following are only used if you are writing an upload handler:
FILE_UPLOADS
- A mapping of input names -> tmp filesFILE_UPLOAD_TYPES
- A mapping of input names -> file upload types (according to the request)FILE_UPLOAD_NAMES
- A mapping of input names -> original filenamesYou can return any of the following HTTP codes from an endpoint:
# example
return $(status_code 404)