exyus pipeline details
the exyus web engine works on an XML transformation pipeline model. although it does not implement the W3C XML Pipeline standard, it works in a similar way. now that the engine is starting reach a steady-state, i figured is was worth the time to outline the details of the pipeline as it is currently implemented.
the big picture
in exyus, there are several 'transformation/validation points' that can be implemented. most of them are optional. they are (in order):
- argument validation
- all incoming arguments are captured as an XML document and can be validated using XSD. this is usually done in order to make sure all the required arguments were supplied by the client. these arguments are also available as a list of XSL parameters for the life for the request (see below)
- request body validation
- the body sent with the request is captured as an XML document and can be validated using XSD. this is usually done to make sure any incoming request has the proper input fields, that the fields contain the proper data types, ranges, etc.
- request body transformation
- the body sent with the request can be transformed using XSL. this is usually done in order to convert the incoming data into a format suitable for executing the request. for example, the incoming request can be transformed into a valid T-SQL call or it can be transformed into the final format needed to save the information to disk. the list of arguments is also available for this transformation as a set of XSL parameters.
- response body transformation
- the result of the cxommand execution can be transformed using XSL. this is usually done in order to convert the response of the back-end storage system (T-SQL, file system, etc.) into a valid representation for the client. the list of arguments is also available for this transformation as a set of XSL parameters. any additional state information that results from the execution of the command (new document id, date-time stamp, location on disk, etc.) is also available as an XSL argument.
ok, so much for the general pattern. below is a step-by-step set of transformation and validation points for the four key HTTP Methods supported by the exyus web engine. note that in almost all cases, these validation and transformation steps are optional.
workflow for handling HTTP DELETE
- collect URL + arguments
- convert into -args- document
- validate -args- document
- transform -args- into valid delete document (t-sql, physical file)
- execute delete
- return 204 (no content)
workflow for handling HTTP GET
- collect URL + arguments
- convert into -args- document
- validate -args- document
- transform -args- into valid read document (t-sql, physical file)
- execute read
- transform results into valid response representation
- return 200 + representation
workflow for handling HTTP POST
- collect URL + arguments
- convert into -args- document
- validate -args- document
- collect body entity
- convert into -body- document
- validate -body- document
- transform -body- into valid save document (t-sql, physical file)
- execute save
- transform results into valid response representation
- if redirect-on-create, then send 302 (found) + new URL
- else return 200 + representation
workflow for handling HTTP PUT
- collect URL + arguments
- convert into -args- document
- validate -args- document
- collect body entity
- convert into -body- document
- validate -body- document
- collect headers (if-match, if-unmodified-since, content-type)
- compose HEAD call (w/ headers) to existing URL
- collect resulting headers (etag, last-modified)
- evaluate results
- HEAD = 200 OK, it's ok to update
- HEAD = 304 not-modified, it's ok to update
- HEAD = 404 not found, not an update, check if it's OK to create
- if not-ok-to-save, send 412 (pre-condition failed) and exit
- else transform -body- into valid save document (t-sql, physical file)
- execute save
- transform results into valid response representation
- return 200 + representation