Parsoid and RESTBase use a "domain" in order to identify configurations for different wikis. By default the "domain" is derived from hostname portion of the mediawiki Action API URL. This is a reasonable default for many users.
However, in actuality the "domain" can be a completely arbitrary string. If you host multiple wikis on a single domain, you may want to take advantage of this flexibility.
First, when you configure Parsoid in localsettings.js
you'll want to explicitly specify the "domain" string you want to use. For example:
parsoidConfig.setMwApi("wiki1prefix", { uri: "http://myhost/wiki1/api.php", domain: "wiki1" });
parsoidConfig.setMwApi("wiki2prefix", { uri: "http://myhost/wiki2/api.php", domain: "wiki2" });
Then you'll need to configure RESTBase similarly. For example:
spec: &spec
title: "The RESTBase root"
# Some more general RESTBase info
paths:
/{domain:wiki1}:
...
/{domain:wiki2}:
...
and
/{module:action}:
x-modules:
- name: action
type: file
options:
apiRequest:
method: post
uri: 'http://localhost/{$.request.params.domain}/api.php'
headers:
host: 'localhost'
body: '{$.request.body}'
(You can use {domain}
as a shortcut for {$.request.params.domain}
.)
If your chosen domain strings are completely arbitrary, you will need to copy the big yaml block starting with wmf-sys-1.0.0: &wp/sys/1.0.0
and rename them. For example:
wmf-sys-1.0.0-1: &wp1/sys/1.0.0
...
apiRequest:
method: post
uri: 'http://arbitrary/url/here/api.php'
headers:
host: 'arbitrary'
body: '{$.request.body}'
wmf-sys-1.0.0-2: &wp2/sys/1.0.0
...
apiRequest:
method: post
uri: 'http://other/url/here/api.php'
headers:
host: 'other'
body: '{$.request.body}'
spec: &spec
title: "The RESTBase root"
# Some more general RESTBase info
paths:
/{domain:wiki1}:
x-subspecs:
- paths:
# Mount the content API at /localhost/v1/
/{api:v1}:
x-subspec: *wp/content/1.0.0
- paths:
# Mount the internal modules at /localhost/sys/
/{api:sys}:
x-subspec: *wp1/sys/1.0.0
/{domain:wiki2}:
x-subspecs:
- paths:
# Mount the content API at /localhost/v1/
/{api:v1}:
x-subspec: *wp/content/1.0.0
- paths:
# Mount the internal modules at /localhost/sys/
/{api:sys}:
x-subspec: *wp2/sys/1.0.0
Note that at the root level "domain:wiki1" refers to yaml entity "wp1/sys/1.0.0" (the first big block) and "domain:wiki2" refers to yaml entity "wp2/sys/1.0.0" (the second, copied, big block).