I am trying to bring up a few quick Mock APIs using Deployd. Some of these APIs have to use data from HTTP Header. How do get a handle to the HTTP header in Deployd?
1 Answers
Here's a working example: https://gist.github.com/marshallswain/8087915 I have only tested the ON GET script, but the others should work.
You have to create a custom Deployd module and extend the collection
resource.
To create the above module, I "borrowed" code from the main Collection class and modified the createDomain function to allow for adding context variables. You can add or remove ctx parameters in the domain variable to customize it to your liking.
Deployd scripts (the ON GET and ON POST ones you find in the dashboard) have a limited scope by default (actually, it's called context or ctx in the code), so they don't get access to the request headers by default. Here is a list of the variables that they do have access to: http://docs.deployd.com/docs/collections/reference/event-api.md.
This gives you some documentation on how you can create your own Collection. http://docs.deployd.com/docs/developing-modules?include=all#s-Collection%20Resource%20Type

- 945
- 2
- 8
- 17