Item12932: Allow REST to accept the contenttype parameter
Priority: Enhancement
Current State: Proposal Required
Released In: n/a
Target Release: minor
It is possible to pass the GET Param "contenttype" to a topic on view, to define the response Content-Type.
Would it be possible that we can pass this Param also to a rest call (/wiki/bin/rest/...)?
--
MarcKloter - 04 Jun 2014
Currently the
UI::Rest
does not process or pass through the content type. REST handlers have two implementation options:
- Return the results at the end of processing.
UI::Rest
calls writeCompletePage
with the content, and the core returns it as text/html
- Handle the output directly. The REST handler is then free to set whatever content type and status code that it wants. So this depends upon the implementation of the handler.
I could see this being a rather minor enhancement, possibly for 1.2. This would make
rest
consistent with
view
and
edit
- In the
UI::Rest
handler, validate the contenttype
parameter for possible use if provided.
- Change the REST API to return either the simple results, or an array
($response, $contenttype)
So the general implementation:
- In
UI::Rest
, process the return from the REST handler as follows:
- If return is empty, do nothing. The handler generated any output.
- If return is an array, use the provided contenttype in the response
- If return is a simple string, validate the urlparam
contenttype
, otherwise default to text/html.
- If a result is available
- Call
$session->writeCompletePage( $response, 'rest', $contentType );
--
GeorgeClark - 07 Jun 2014
Deferring this to Foswiki 2.0
--
GeorgeClark - 24 Apr 2015
Deferring to 2.1.
--
Main.GeorgeClark - 06 Jul 2015 - 03:27
As this is an API change, it really should have a proposal. Deferring to a future release.
--
GeorgeClark - 17 Dec 2015