philbooth · GitHub

@philbooth

Not wired in to any behaviour, just does some crude validation and then
returns a hard-coded message id. There is some test coverage, but also
some gaps where I haven't figured out how we should do stuff yet:
* The validation code is punishingly verbose. I evauated a couple of
  crates to implement validation, `accord` and `validator`, and opted
  for `validator`. However they both seem quite simple, for instance
  there's no support for nested objects or values packed inside arrays.
  This meant we couldn't lean on the nice, readable macro syntax that's
  available and have to explitly validate fields using Rocket's FromData
  trait instead.
* Rocket has a feature called error catchers, which I couldn't get to
  work. These are supposed to let you return custom error data but, no
  matter what I tried, it always seemed to return the default error
  response for each type (which is an html string). And even if I could
  get those to work, I couldn't see a way to propagate rich error
  information, e.g. names of invalid parameters, into the catcher
  without having to validate all of the parameters a second time inside
  the catcher.
* I tried to write a test case that fired unicode at the endpoint and it
  failed.
I'm sure the root cause of these problems is just my own lack of
expertise and we'll figure it out eventually. In the meantime, this
seemed like enough to get us started. I'll open issues to cover the
above.
In terms of code structure, I've just lumped most stuff in to the send
module for now. As we add more functionality, I expect the natural
boundaries to reveal themselves. No point agonising over it yet.

Read the original on github.com ↗