Skip to content

Instantly share code, notes, and snippets.

@s3u
Created February 22, 2012 08:32
Show Gist options
  • Save s3u/1883435 to your computer and use it in GitHub Desktop.
Save s3u/1883435 to your computer and use it in GitHub Desktop.
ql.io: Making Peace with Bad HTTP APIs

Step 1: Create a table

create table aws.swf
  on insert post to 'http://swf.us-east-1.amazonaws.com/'
  using headers 'X-Amz-Target' = 'com.amazonaws.swf.service.model.SimpleWorkflowService.RegisterDomain',
            'X-Amx-Encoding' = 'amz-1.0',
            'X-Amzn-Authorization' = '...'
  using bodyTemplate 'foo.json.mu' type 'application/json';       

Step 2: Describe the shape of the request body

{"name": "{{params.name}}",
 "description": "{{params.desc}}",
 "workflowExecutionRetentionPeriodInDays": "{{params.retention}}"}

Step 3: Wrap with a saner interface

resp = insert into aws.swf (name, desc, retention) values ('{name}', '{desc}', '{rentention}');
return resp via route '/blah' using method put;

Step 4: Use with peace

PUT /blah?name=xx&desc=yy&rention=zz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment