Services/BestPractices

From MozillaWiki
< Services
Revision as of 16:15, 15 February 2012 by Ametaireau (talk | contribs) (Created page with "==== Best practices ==== This page lists the best practices we try to follow when developing services-related code. Please, add your thoughts and best bractices here. It is a go...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Best practices

This page lists the best practices we try to follow when developing services-related code. Please, add your thoughts and best bractices here. It is a good place to get started on how to contribute.

Dealing with errors / validation

When validating inputs using different validation mechanisms, you would sometimes like to return errors. Do it in JSON, with the following format.

The default returned JSON object is a dictionary of the following form:

   {
       'status': 'error',
       'errors': errors.
   }

With errors being a JSON dictionary with the keys “location”, “name” and “description”.

  • location is the location of the error. It can be “querystring”, “header” or “body”
  • name is the eventual name of the value that caused problems
  • description is a description of the problem encountered.


Packaging