MediaWiki  master
MediaWiki\Rest\Router Class Reference

The REST router is responsible for gathering handler configuration, matching an input path and HTTP method against the defined routes, and constructing and executing the relevant handler for a request. More...

Public Member Functions

 __construct ( $routeFiles, $extraRoutes, ServiceOptions $options, BagOStuff $cacheBag, ResponseFactory $responseFactory, BasicAuthorizerInterface $basicAuth, Authority $authority, ObjectFactory $objectFactory, Validator $restValidator, ErrorReporter $errorReporter, HookContainer $hookContainer, Session $session)
 
 execute (RequestInterface $request)
 Find the handler for a request and execute it. More...
 
 getPrivateRouteUrl (string $route, array $pathParams=[], array $queryParams=[])
 Returns a full private URL for the given route. More...
 
 getRouteUrl (string $route, array $pathParams=[], array $queryParams=[])
 Returns a full URL for the given route. More...
 
 setCors (CorsUtils $cors)
 

Protected Member Functions

 substPathParams (string $route, array $pathParams)
 

Detailed Description

The REST router is responsible for gathering handler configuration, matching an input path and HTTP method against the defined routes, and constructing and executing the relevant handler for a request.

Definition at line 25 of file Router.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Rest\Router::__construct (   $routeFiles,
  $extraRoutes,
ServiceOptions  $options,
BagOStuff  $cacheBag,
ResponseFactory  $responseFactory,
BasicAuthorizerInterface  $basicAuth,
Authority  $authority,
ObjectFactory  $objectFactory,
Validator  $restValidator,
ErrorReporter  $errorReporter,
HookContainer  $hookContainer,
Session  $session 
)
Parameters
string[]$routeFilesList of names of JSON files containing routes
array$extraRoutesExtension route array
ServiceOptions$options
BagOStuff$cacheBagA cache in which to store the matcher trees
ResponseFactory$responseFactory
BasicAuthorizerInterface$basicAuth
Authority$authority
ObjectFactory$objectFactory
Validator$restValidator
ErrorReporter$errorReporter
HookContainer$hookContainer
Session$session
Access: internal

Definition at line 108 of file Router.php.

References MediaWiki\Config\ServiceOptions\assertRequiredOptions(), MediaWiki\MainConfigNames\CanonicalServer, MediaWiki\Config\ServiceOptions\get(), MediaWiki\MainConfigNames\InternalServer, and MediaWiki\MainConfigNames\RestPath.

Member Function Documentation

◆ execute()

MediaWiki\Rest\Router::execute ( RequestInterface  $request)

Find the handler for a request and execute it.

Parameters
RequestInterface$request
Returns
ResponseInterface

Definition at line 352 of file Router.php.

References $path, MediaWiki\Rest\RequestInterface\getMethod(), MediaWiki\Rest\RequestInterface\getUri(), and MediaWiki\Rest\RequestInterface\setPathParams().

◆ getPrivateRouteUrl()

MediaWiki\Rest\Router::getPrivateRouteUrl ( string  $route,
array  $pathParams = [],
array  $queryParams = [] 
)

Returns a full private URL for the given route.

Private URLs are for use within the local subnet, they may use host names or ports or paths that are not publicly accessible. Intended for use in redirects and when including links to endpoints in output.

Note
Only private endpoints should use this method for redirects or links to include on the response! Public endpoints should not expose the URLs of private endpoints to the public!
Since
1.39
See also
getRouteUrl
Parameters
string$route
array$pathParams
array$queryParams
Returns
string

Definition at line 319 of file Router.php.

◆ getRouteUrl()

MediaWiki\Rest\Router::getRouteUrl ( string  $route,
array  $pathParams = [],
array  $queryParams = [] 
)

Returns a full URL for the given route.

Intended for use in redirects and when including links to endpoints in output.

Parameters
string$route
array$pathParams
array$queryParams
Returns
string
See also
getPrivateRouteUrl

Definition at line 290 of file Router.php.

◆ setCors()

MediaWiki\Rest\Router::setCors ( CorsUtils  $cors)
Parameters
CorsUtils$cors
Returns
self

Definition at line 504 of file Router.php.

◆ substPathParams()

MediaWiki\Rest\Router::substPathParams ( string  $route,
array  $pathParams 
)
protected
Parameters
string$route
array$pathParams
Returns
string

Definition at line 335 of file Router.php.


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