ocsigen / eliom

Multi-tier framework for programming web and mobile applications in OCaml.
http://eliom.org
Other
298 stars 53 forks source link

Eliom services and return code #332

Open Drup opened 8 years ago

Drup commented 8 years ago

Since we are in the middle of redesigning the whole service stuff, could we solve that embarrassing problem where we need to use Any to return different error codes ?

vasilisp commented 8 years ago

What would be the API? I can imagine an Eliom_registration.Almost_any (placeholder name) that lets you register handlers of the form

get -> post -> [`Page of page | `Redirection of uri | `Four_oh_four | ... ]

Or maybe the handlers for existing service types can throw special exceptions that trigger a specific code.

And the most important question, should we really provide an abstraction for this case? Isn't it quite rare?

Drup commented 8 years ago

Why not simply handlers of the form (get -> post -> result Lwt.t), result being the type returned by send ? It would mean having an explicit return, which doesn't sound like such a terrible thing.

Drup commented 8 years ago

Well, now that I said it, I realize it's equivalent to just removing everything except Any ... which actually may be a good thing.

vasilisp commented 8 years ago

If we do what you describe, won't we need to emphasize the various send functions for producing result out of disparate inputs (TyXML nodes, text, redirection, ...)? In the current version, send is of mostly internal interest, so from a user's perspective we are going from a single-level API (disparate create / register) to a two-level API (disparate send + uniform create / register). It seems to me that we do not really get any uniformity, and we make the API more inconvenient...