Framework Overview & Recent Changes
This content outlines the traffic operations CRUD framework created by Dylan Volz for the TC Summit in Boxborough, MA. It covers routing basics, middleware, handler types, generic handlers, and recent/future changes in the framework's development, emphasizing decoupling and flexibility for improved implementation. Visual aids accompany each section.
Download Presentation
Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
E N D
Presentation Transcript
TRAFFIC OPS CRUD FRAMEWORK Dylan Volz TC Summit - Boxborough, MA
Routing basics The routes are compiled and registered with the base handler They are processed in the order they appear in the file Regexes are used for path matching Future considerations: Processing a list for regex matches may have performance implications
Middleware A set of optional request/response modifiers Headers (Access-Control-Allow-*, Whole-Content-SHA512) User Authorization (optionally applied based on the authentication field of the route) Capabilities (Future)
Handler Three main types currently: Proxy passthrough handler -> routes request to Mojolicious server We currently don t use the headers or authorization middleware since mojo handles it Standard handler -> accepts the request body and responds Needs to unmarshal the JSON body, collect the parameters and user info from the context, check tenancy, handle the request, changelog entry, build a response body and set the content type ping Generic CRUD handler -> Normalizes the steps above around a Create, Read, Update, or Delete operation on a struct.
Generic Handlers Implemented using interfaces Identifier Information about how to represent the struct Tenatable optional Validator Used to validate the request body after decoding CRUD interfaces Very similar code in each implementation Flexibility versus verbosity
Recent and future changes Id based -> definable key set Remove sqlx.DB from interface definitions Decouples implementation greater flexibility Replace type reference with singleton Removes concurrency bug on delete