Skip to content

Instantly share code, notes, and snippets.

@Pchelolo
Last active August 26, 2015 17:01
Show Gist options
  • Save Pchelolo/fe8d45302028d213d70a to your computer and use it in GitHub Desktop.
Save Pchelolo/fe8d45302028d213d70a to your computer and use it in GitHub Desktop.
/{module:graphoid}:
x-modules:
- name: simple_service
version: 1.0.0
type: file
options:
paths:
# Do we need those parameters??
/v1/png/{title}/{revision}:
post:
on_setup:
- setup_post_storage:
method: put
uri: /{domain}/sys/key_value/graphoid.post
- setup_png_storage:
method: put
uri: /{domain}/sys/key_value/graphoid.png
on_request:
# Don't know how to make posts to graphoid correctly and which data to post there
- graphoid_request:
request:
method: post
uri: http://graphoid.wikimedia.org/{domain}/v1/png/{title}/{revision}
body: '{$.request.body}'
save_post_request:
request:
method: put
# TODO URI substitution like this is not supported!!
uri: /{domain}/sys/key_value/graphoid.post/{$.request.hash}
body: '{$.request}'
- store_result:
request:
method: put
# TODO URI substitution like this is not supported!!
uri: /{domain}/sys/key_value/graphoid.png/{$.request.hash}
body: '{$.graphoid_request.body}'
- return_result:
return:
status: '{$.graphoid_request.status}'
headers:
# Which header are we going to use?
location-hash: '$.request.hash'
body: '{$.graphoid_request.body}'
/v1/png/{title}/{revision}/{hash}:
get:
on_request:
- get_from_storage:
request:
uri: /{domain}/sys/key_value/graphoid.png/{hash}
return_if:
status: 200
catch:
status: 404
- load_post:
request:
uri: /{domain}/sys/key_value/graphoid.post/{hash}
- request_again:
request:
method: post
uri: /v1/png/{title}/{revision}:
headers: '{$.load_post.headers}'
body: '{$.load_post.body}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment