Skip to content
tristanls edited this page Nov 24, 2012 · 2 revisions

POST https://api.worker.crxtalk.com/worker

Upload a new worker.

Since Version 0.2.0
HTTP method POST
Requires login true

Headers

Content-Type multipart/form-data; boundary=BOUNDARY required Standard multipart Content-Type header must be included
crosstalkToken ausdudsl112347assj2... required Authorization token

Parameters

None.

POST Body

Multipart form-data containing "worker" and "package" files.

--BOUNDARY
Content-Disposition: form-data; name="worker"; filename="index.js"
Content-Type: text/plain

...
--BOUNDARY
Content-Disposition: form-data; name="package"; filename="package.json"
Content-Type: application/json

...
--BOUNDARY--

Response fields

Response

url https://api.worker.crxtalk.com/worker/my-worker/0.0.2 The url to the uploaded worker (notice that it is encoded as WORKER_NAME/VERSION)
### Error
message Some error happened An error message
## Example `POST https://api.worker.crxtalk.com/worker`
Content-Type: multipart/form-data; boundary=MY_BOUNDARY
crosstalkToken: ausdudsl112347assj2...

--MY_BOUNDARY
Content-Disposition: form-data; name="worker"; filename="index.js"
Content-Type: text/plain

crosstalk.on( "hello", function () {
  crosstalk.emit( "world" );
});

--MY_BOUNDARY
Content-Disposition: form-data; name="package"; filename="package.json"
Content-Type: application/json

{
  "name": "my-worker",
  "description": "Canonical Hello World worker.",
  "version": "0.0.2",
  "crosstalk": {
    "type": "worker"
  }
}

Response:

201 Created
Location: https://api.worker.crxtalk.com/worker/my-worker/0.0.2

{ 
  "response" : {
    "url" : "https://api.worker.crxtalk.com/worker/my-worker/0.0.2" 
  }
}

Error:

400 Bad Request
{ "error" : { "message" : "Some error happened" } }
Clone this wiki locally