Config 2: Mime Types

  1. General Properties
  2. Mime Types
    1. HTML Types
    2. JSON
    3. JSONP
    4. XML
  3. Authentication & Authorization
  4. URL Handling 
  5. Tasks

 

Every request has a mime tag in the URL and so Genelet knows what type of content, HMTL, JSON or XML, should be returned to the visitor. The tag lets you easily present your website in different foreign languages too.

For example, if you visit
http://WEBSITE/HANDLER/role/e/component?action=string&query….
where e is defined to be HTML type in English. Genelet will render the page according to the template at Template/role/component/action.e.

You can define s to be HTML type in Spanish. Request to
http://WEBSITE/HANDLER/role/s/component?action=string&query….
will render the same page in Spanish according to the template at Template/role/component/action.s.

Furthermore, you may define tag j for JSON. in case of JSON (and XML) requests, no template is needed. Genelet internally converts the returned data into a JSON string. There are 4 blocks there:

  • data” : the main data structure returned, presented as an array of objects;
  • relationships” : the associated data structures, presented as an object;
  • incoming“: original requesting variables by the client, presented as a hash;
  • included“: extra requesting variables, determined from the URL and cookie.

(Note that there is no JSON API standard yet. Genelet would match such a standard in the future.)

In config.json, the mime types are put in Chartags. Here is an example:

"Chartags" : {
  "e":{
    "Content_type":"text/html; charset=\"UTF-8\"",
    "Short":"ehtml"
  },
  "s":{
    "Content_type":"text/html; charset=\"UTF-8\"",
    "Short":"shtml"
  },
  "j":{
    "Content_type":"application/json; charset=\"UTF-8\"",
    "Short":"json",
    "Challenge":"challenge",
    "Logged":"logged",
    "Logout":"logout",
    "Failed":"failed",
    "Case":1
  }
}