Julian Doherty
I'm gonna be that guy in a minute
Wrapping REST around MVC is a leaky abstraction
authentication; content type negotiation; caching; redirects; language; http verbs; status codes...
Actually, doing HTTP "just ok" isn't too hard
But doing HTTP properly is HARD
So... do I return a 201 Created
... Or a 409 Conflict
... or 417 Expectation Failed
?... What if the client accepts JSON but has a character set I don't know about?... What if I don't implement that method on that resource?... What if caching headers don't match?... What if the resource doesn't exist, but it's being updated?... Or what about...
Original written in Erlang. Still going strong
Talking about Ruby port today
So let's just define functions to handle the decision points
resource_exists? service_available? is_authorized? forbidden? allow_missing_post? malformed_request? uri_too_long? known_content_type? valid_content_headers? valid_entity_length? options allowed_methods known_methods delete_resource delete_completed? post_is_create? create_path base_uri process_post content_types_provided content_types_accepted charsets_provided languages_provided language_chosen encodings_provided variances is_conflict? multiple_choices? previously_existed? moved_permanently? moved_temporarily? last_modified expires generate_etag finish_request handle_exception validate_content_checksum
Julian Doherty
/
#