reitit

Uploading Files and Handling Upload Requests in Clojure[script]

What’s the secret? I have used ajax uploads and interactions in Clojure forever; it’s a bread-and-butter skill to use AJAX and JSON1. However, my WordPress usage led me to believe it would be equally trivial to handle file uploads. It turned out to be less trivial than I expected, though. In summary, the secrets I needed were: Make sure the encType on the client is "multipart/form-data", which happens differently with AJAX than with plain HTML

Fine-grained per-method middleware use with Reitit

Fact: I have middleware performing authentication (in this case, my CAS authentication middleware) Need: This middleware should apply to client-facing SPA-rendered views, which are requested via GET. Constraint: This middleware does NOT apply to non-get routes (which are headless so the authentication must be handled differently) Constraint: There exist headless GET routes, too, which should not be CAS authenticated Constraint: Individual routes may have a CAS-authenticated GET response, as well as non-CAS POST, PATCH, and DELETE responses Reitit allowed me to specify middleware on a delightfully granular level to solve this.

Adding Custom Transit Handlers to re-frame-http-fx AJAX requests

Setting the Scene Transit is a seamless alternative to JSON (actually an extension of JSON). Why use Transit when JSON is so prevalent? For me, the simple reason was that it allows me to preserve my data types (mine are Clojure, but they are not necessarily such) over the wire. For me in particular this was my time types, and my uuids (which I wanted to standardize so they stop alternating between UUIDs, strings, and keywords, for matching purposes).