You are here: Foswiki>Tasks Web>Item12932 (17 Dec 2015, GeorgeClark)Edit Attach

Item12932: Allow REST to accept the contenttype parameter

pencil
Priority: Enhancement
Current State: Proposal Required
Released In: n/a
Target Release: minor
Applies To: Engine
Component: FoswikiUIRest
Branches:
Reported By: MarcKloter
Waiting For:
Last Change By: GeorgeClark
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
 

ItemTemplate edit

Summary Allow REST to accept the contenttype parameter
ReportedBy MarcKloter
Codebase 1.1.9, 1.1.5, trunk
SVN Range
AppliesTo Engine
Component FoswikiUIRest
Priority Enhancement
CurrentState Proposal Required
WaitingFor
Checkins
TargetRelease minor
ReleasedIn n/a
CheckinsOnBranches
trunkCheckins
masterCheckins
ItemBranchCheckins
Release02x00Checkins
Release01x01Checkins
Topic revision: r5 - 17 Dec 2015, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy