As we expand beyond Parsoid we need a way to expose and (optionally) store relatively simple responses from backend services. We should make this module fairly generic, so that we can easily configure it to support many services with similar caching needs.
Use cases:
- [Citoid](https://www.mediawiki.org/wiki/Citoid/API#Examples)
- store JSON blob per `format` and `search` parameter (key), if response was 200
- could alos store only per `search`, but outputting the right format would need further work in the backend module
- [Graphoid](https://www.mediawiki.org/wiki/Extension:Graph#Graphoid_Service)
- store image under hash key
- forward title, rev, hash to service on cache miss: /PageTitle/12345/a64b022a8fa5b7fc5e40a2c95cd0a114b2ae1174.png
- MobileApps
- store mobile-friendly HTML version of the page, store under key and revision
- forward //title, rev// to service on cache miss
- [RevisionScoring service](https://meta.wikimedia.org/wiki/Research:Revision_scoring_as_a_service)
- generate and store JSON metadata per title & revision
Requirements:
- Provide an internal service end point, and map requests to storage & backend service requests. The backend request format needs to be configurable.
- URI format in spec needs to define `key` and optionally `revision`.
- Store responses from GETs, and only if no query parameters were supplied.
- Optionally (if configured) support refreshing content with a `Cache-control: no-cache` header.
Draft module config in config.yaml:
```
/{module:simple_service}:
x-modules:
- name: simple_service
version: 1.0.0
type: file
options:
paths:
/someservice/foo/{key}:
get:
backend_request:
uri: http://some.svc.eqiad.wmnet:12345/{key}
storage:
no-cache_refresh: true
bucket_request:
uri: /{domain}/sys/key_value/someservice.foo
item_request:
uri: /{domain}/sys/key_value/someservice.foo/{key}
```
Draft PR: https://github.com/wikimedia/restbase/pull/229