MediaWiki  1.32.5
RestbaseVirtualRESTService Class Reference

Virtual HTTP service client for RESTBase. More...

Inheritance diagram for RestbaseVirtualRESTService:
Collaboration diagram for RestbaseVirtualRESTService:

Public Member Functions

 __construct (array $params)
 Example RESTBase v1 requests: GET /local/v1/page/html/{title}{/revision} POST /local/v1/transform/html/to/wikitext{/title}{/revision}. More...
 
 onParsoid1Request (array $req, Closure $idGeneratorFunc)
 Remap a Parsoid v1 request to a RESTBase v1 request. More...
 
 onParsoid3Request (array $req, Closure $idGeneratorFunc)
 Remap a Parsoid v3 request to a RESTBase v1 request. More...
 
 onParsoidRequests (array $reqs, Closure $idGeneratorFunc)
 Remaps Parsoid v1/v3 requests to RESTBase v1 requests. More...
 
 onRequests (array $reqs, Closure $idGenFunc)
 Prepare virtual HTTP(S) requests (for this service) for execution. More...
 
- Public Member Functions inherited from VirtualRESTService
 getName ()
 Return the name of this service, in a form suitable for error reporting or debugging. More...
 
 onResponses (array $reqs, Closure $idGeneratorFunc)
 Mangle or replace virtual HTTP(S) requests which have been responded to. More...
 

Additional Inherited Members

- Protected Attributes inherited from VirtualRESTService
array $params = []
 Key/value map. More...
 

Detailed Description

Virtual HTTP service client for RESTBase.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. http://www.gnu.org/copyleft/gpl.html Virtual REST service for RESTBase

Since
1.25

Definition at line 25 of file RestbaseVirtualRESTService.php.

Constructor & Destructor Documentation

◆ __construct()

RestbaseVirtualRESTService::__construct ( array  $params)

Example RESTBase v1 requests: GET /local/v1/page/html/{title}{/revision} POST /local/v1/transform/html/to/wikitext{/title}{/revision}.

  • body: array( 'html' => ... ) POST /local/v1/transform/wikitext/to/html{/title}{/revision}
  • body: array( 'wikitext' => ... ) or array( 'wikitext' => ..., 'body_only' => true/false )
Parameters
array$paramsKey/value map
  • url : RESTBase server URL
  • domain : Wiki domain to use
  • timeout : request timeout in seconds (optional)
  • forwardCookies : cookies to forward to RESTBase/Parsoid (as a Cookie header string) or false (optional) Note: forwardCookies will in the future be a boolean only, signifing request cookies should be forwarded to the service; the current state is due to the way VE handles this particular parameter
  • HTTPProxy : HTTP proxy to use (optional)
  • parsoidCompat : whether to parse URL as if they were meant for Parsoid boolean (optional)
  • fixedUrl : Do not append domain to the url. For example to use English Wikipedia restbase, you would this to true and url to https://en.wikipedia.org/api/rest_#version#

Reimplemented from VirtualRESTService.

Definition at line 51 of file RestbaseVirtualRESTService.php.

References VirtualRESTService\$params.

Member Function Documentation

◆ onParsoid1Request()

RestbaseVirtualRESTService::onParsoid1Request ( array  $req,
Closure  $idGeneratorFunc 
)

Remap a Parsoid v1 request to a RESTBase v1 request.

Example Parsoid v1 requests: GET /local/v1/page/$title/html/$oldid

  • $oldid is optional POST /local/v1/transform/html/to/wikitext/$title/$oldid
  • body: array( 'html' => ... )
  • $title and $oldid are optional POST /local/v1/transform/wikitext/to/html/$title
  • body: array( 'wikitext' => ... ) or array( 'wikitext' => ..., 'body' => true/false )
  • $title is optional

NOTE: the POST APIs aren't "real" Parsoid v1 APIs, they are just what Visual Editor "pretends" the V1 API is like. (See ParsoidVirtualRESTService.)

Parameters
array$req
Closure$idGeneratorFunc
Returns
array
Exceptions
Exception
Deprecated:
since 1.26, upgrade your client to issue v3 requests.

Definition at line 158 of file RestbaseVirtualRESTService.php.

References $req, $title, list, and wfDeprecated().

Referenced by onParsoidRequests().

◆ onParsoid3Request()

RestbaseVirtualRESTService::onParsoid3Request ( array  $req,
Closure  $idGeneratorFunc 
)

Remap a Parsoid v3 request to a RESTBase v1 request.

Example Parsoid v3 requests: GET /local/v3/page/html/$title/{$revision}

  • $revision is optional POST /local/v3/transform/html/to/wikitext/{$title}{/$revision}
  • body: array( 'html' => ... )
  • $title and $revision are optional POST /local/v3/transform/wikitext/to/html/{$title}{/$revision}
  • body: array( 'wikitext' => ... ) or array( 'wikitext' => ..., 'body_only' => true/false )
  • $title is optional
  • $revision is optional
    Parameters
    array$req
    Closure$idGeneratorFunc
    Returns
    array
    Exceptions
    Exception

Definition at line 251 of file RestbaseVirtualRESTService.php.

References $req, and list.

Referenced by onParsoidRequests().

◆ onParsoidRequests()

RestbaseVirtualRESTService::onParsoidRequests ( array  $reqs,
Closure  $idGeneratorFunc 
)

Remaps Parsoid v1/v3 requests to RESTBase v1 requests.

Parameters
array$reqs
Closure$idGeneratorFunc
Returns
array
Exceptions
Exception

Definition at line 120 of file RestbaseVirtualRESTService.php.

References $req, as, onParsoid1Request(), and onParsoid3Request().

Referenced by onRequests().

◆ onRequests()

RestbaseVirtualRESTService::onRequests ( array  $reqs,
Closure  $idGeneratorFunc 
)

Prepare virtual HTTP(S) requests (for this service) for execution.

This method should mangle any of the $reqs entry fields as needed:

  • url : munge the URL to have an absolute URL with a protocol and encode path components as needed by the backend [required]
  • query : include any authentication signatures/parameters [as needed]
  • headers : include any authentication tokens/headers [as needed]

The incoming URL parameter will be relative to the service mount point.

This method can also remove some of the requests as well as add new ones (using $idGenerator to set each of the entries' array keys). For any existing or added request, the 'response' array can be filled in, which will prevent the client from executing it. If an original request is removed, at some point it must be added back (with the same key) in onRequests() or onResponses(); it's reponse may be filled in as with other requests.

Parameters
array$reqsMap of Virtual HTTP request arrays
Closure$idGeneratorFuncMethod to generate unique keys for new requests
Returns
array Modified HTTP request array map

Reimplemented from VirtualRESTService.

Definition at line 78 of file RestbaseVirtualRESTService.php.

References $req, as, and onParsoidRequests().


The documentation for this class was generated from the following file: