Skip to content

Commit

Permalink
Made the service URI configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Pchelolo committed Nov 24, 2016
1 parent 5b87d65 commit e791f8b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
7 changes: 5 additions & 2 deletions config.example.wikimedia.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ default_project: &default_project
cache_control: s-maxage=86400, max-age=86400
# 10 days Varnish caching, one day client-side
purged_cache_control: s-maxage=864000, max-age=86400
# Cache PDF for 5 minutes since it's not purged
pdf_cache_control: s-maxage=300, max-age=300
pdf:
# Cache PDF for 5 minutes since it's not purged
cache_control: s-maxage=600, max-age=600
uri: https://pdf-electron.wmflabs.org/pdf
secret: secret
skip_updates: false

# A different project template, sharing configuration options.
Expand Down
5 changes: 5 additions & 0 deletions config.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ default_project: &default_project
host: http://appservice.wmflabs.org
events: {}
purged_cache_control: test_purged_cache_control
pdf:
# Cache PDF for 5 minutes since it's not purged
cache_control: s-maxage=600, max-age=600
uri: https://deployment-pdfrender.deployment-prep.eqiad.wmflabs/pdf
secret: secret
skip_updates: false

labs_project: &labs_project
Expand Down
3 changes: 1 addition & 2 deletions projects/wmf_default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ paths:
options: '{{merge({"random_cache_control": "s-maxage=2, max-age=1"},
options.mobileapps)}}'
- path: v1/pdf.yaml
options:
response_cache_control: '{{options.pdf_cache_control}}'
options: '{{options.pdf}}'
/feed:
x-modules:
- path: v1/feed.js
Expand Down
3 changes: 1 addition & 2 deletions projects/wmf_wiktionary.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ paths:
response_cache_control: '{{options.purged_cache_control}}'
host: '{{options.mobileapps.host}}'
- path: v1/pdf.yaml
options:
response_cache_control: '{{options.pdf_cache_control}}'
options: '{{options.pdf}}'
/transform:
x-modules:
- path: v1/transform.yaml
Expand Down
20 changes: 12 additions & 8 deletions v1/pdf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@ paths:
description: The PDF render of an article
schema:
type: file
# TODO: Add an etag somehow. How???
#headers:
# ETag:
# description: >
# Syntax: "{revision}/{tid}".
# Example: "701384379/154d7bca-c264-11e5-8c2f-1b51b33b59fc"
headers:
ETag:
description: >
Syntax: "{revision}/{tid}".
Example: "701384379/154d7bca-c264-11e5-8c2f-1b51b33b59fc"
'404':
description: Unknown page title
schema:
Expand All @@ -54,17 +53,22 @@ paths:
$ref: '#/definitions/problem'

x-request-handler:
- get_latest_revision:
request:
method: get
uri: /{domain}/sys/page_revisions/page/{title}
- get_pdf_from_backend:
request:
method: get
uri: 'https://pdf-electron.wmflabs.org/pdf?accessKey=secret&url=https://{{domain}}/wiki/{title}'
uri: '{{options.uri}}?accessKey={options.secret}&url=https://{{domain}}/wiki/{title}'
return:
status: 200
headers:
content-disposition: 'attachment; filename={{request.params.title}}.pdf'
content-type: '{{get_pdf_from_backend.headers.content-type}}'
content-length: '{{get_pdf_from_backend.headers.content-length}}'
cache-control: '{{default(options.response_cache_control, "s-maxage=300, max-age=300")}}'
cache-control: '{{default(options.cache_control, "s-maxage=600, max-age=600")}}'
etag: '{{get_latest_revision.headers.etag}}'
body: '{{get_pdf_from_backend.body}}'

definitions:
Expand Down

0 comments on commit e791f8b

Please sign in to comment.