I’m trying to write a minimal wiki for fun. GET a page and you’re served its contents decorated in HTML with an “Edit” link. GET that “Edit” link and you’re served HTML forms offering file upload or text editing in an HTML textarea. Would be a great pedagogical project but I’m stuck on something simple…
I’ve found the multipart_form, multipart-form-data and http-multipart-formdata libraries but, thus far, failed to get anything working when a user uploads a file. The multipart_form library looks like the most promising one but, for some reason, when I give it the content-type from cohttp it rejects it with the error “Error ‘Non-terminating unstrctured form’ creating content type”. Despite the docs warning that it doesn’t work properly with files I tried the multipart-form-data library but it dies with the internal error “Invalid_argument iter_multipart” which appears to be a parse error at a “–” boundary. Finally I tried http-multipart-formdata but I couldn’t even figure out how to call its API.
Please can someone advise how I should proceed?
Also, I’ve developed cohttp+lwt, cohttp+async, httpaf+lwt and httpaf+async versions of this code trying to find any combination that works but to no avail, e.g. I switched from async to lwt because I saw multipart-form-data supports lwt and not async out-of-the-box. I also tried opium and ocsigen but found them overwhelming, e.g. the amount of new operators. What is the simplest way to write a minimal wiki in OCaml?