Skip to content
This repository has been archived by the owner on Apr 18, 2018. It is now read-only.

About the router

Avaq edited this page Apr 17, 2012 · 4 revisions

About the router

The route is defined by the REQUEST made by the client.
The request consists of a request_method and a request_uri.
The request methods can be [GET, POST, PUT, DELETE], and will be used in REST context.
The request_uri will be split up into segments divided by slashes (/).
The last segment will be used as "endpoint" and must contain a trailing slash or extension.
The first segment must be "com" or an alias defined in the database.
When the first segment is "com", the second segment must contain a component name.

The router does this:

//example input: "GET http://www.example.com/com/content/articles/how+to+farm"

/com -> call system pre processors
/com/content -> call component pre processors
/com/content/articles -> call component pre processors
/com/content/articles/how+to+farm -> call component pre processors
/com/content/articles/how+to+farm -> call component endpoint processor
/com/content/articles/how+to+farm -> call component post processors
/com/content/articles -> call component post processors
/com/content -> call component post processors
/com -> call system post processors

Pre, post and endpoint processors may be added by individual components. Every component can add processors on any part of any route, with the exception of the first segment.

A pre processor is expected to validate input data and do permission checks.
An endpoint is expected to come up with the output data.
A post-processor may then reshape that output data by for instance wrapping it in templates or adding watermarks etc.

The final data is then gathered by the router, and eventually outputted to the client in the format that was requested using the extension from the last segment.

Clone this wiki locally