-
Notifications
You must be signed in to change notification settings - Fork 0
Protocol
The protocol is very simple. A bundler is attached to an endpoint /bundle
by default. It receives an array of options
by PUT method as JSON. options
can be objects described in heya-io's documentation, URLs as strings, or a mix of both.
It verifies a bundle (all URLs should be whitelisted, empty payload, and big payloads are rejected, and so on). If everything is alright, it issues I/O requests (usually in parallel), collects responses and sends back a JSON object of the following format:
{
"bundle": "bundle",
"results": [
// a list of result items
]
}
Every result item has a following structure:
{
"options": {"url": "/abc"}, // options object
"response": {
"status": 200, // an HTTP status code
"statusText": "OK", // an HTTP status text corresponding to status code
"responseType": "", // taken from options.responseType, or an empty string
"responseText": "{a:1}", // a payload as a string
"headers": "Content-Type: application/json" // raw headers
}
}
In order to profile an I/O implementation, bundler may include optional time
property, which is a number in milliseconds that takes to process a request.
This property can be added on an item level to measure how much time did it take to do an individual I/O request:
{
"options": {"url": "/abc"}, // options object
"time": 200, // in ms
"response": {
// a response object described above
}
}
It can be added on a bundle level to measure the whole bundle:
{
"bundle": "bundle",
"time": 300, // in ms
"results": [
// a list of result items
]
}
This reference implementation implements fully the main protocol and its optional time extension.