Add support for rendering generic HTML as result of handler (#7)
Closed
Andrzej Wójcik (Tigase) opened 1 decade ago
Due Date
2014-08-07

Currently it is only possible to return bytes, string, or Map to be rendered as XML or JSON as result of processing by HTTP API handlers. It would be good to extend this to allow to render HTML, so it would be possible to create pages with documentation or pages with human readable results as result of processing by HTTP API handlers.

Type of returned result should depend (same as until now) on Content-Type HTTP header and type HTTP parameter of a request.

Returned result in HTML should use default style of Tigase installation, see #1751, #1752

Andrzej Wójcik (Tigase) commented 1 decade ago

Implemented simple rendering of generic HTML as result of handler by adding support for creation of templates for every result of every handler. If we create proper file (compatible with GStringTemplateEngine) and we put it under correct name (ie. UsersListGet.html in same folder as UsersList.groovy file containing handler for action GET) and in Accept HTTP header we will suggest text/html as supported type then this renderer will be used to process results of handler before sending them to user. Every browser sends Accept HTTP header containing text/html part as most important accepted result of request so this rendering mechanism would be triggered by every request from browser if it is not changes or if request will not contain HTTP type parameter set to other value (ie. application/xml or @application/json@)

Example file template files are available in project directory next to groovy handlers.

I also introduced support for header and footer files which might be placed in top directory of rest scripts and might contain header and footer parts of page to incude by template files for particular handlers.

issue 1 of 1
Type
New Feature
Priority
Normal
Assignee
RedmineID
2094
Issue Votes (0)
Watchers (0)
Reference
tigase/_server/tigase-http-api#7
Please wait...
Page is in error, reload to recover