Skip to content

Improve request API #68

@rafinskipg

Description

@rafinskipg

Implement a new layer of abstraction for the request API, more focused on the binary and streams treatment:

var options = {
  headers : {},
  useCookies : false,
  withCredentials : true
};

corbel.request
  .get('/adasdad', options)
  .asBlob();

corbel.request
  .get('/mysong.binary.blob', options)
  .asFile('audio/mp3');

//Returns promise

//vs

corbel.request.send({
  method: 'GET',
  url: url
});
//Returns promise

//vs

request.send({
  method: 'GET',
  url: url,
  success: function(data, status, httpResponse) {
    expect(data).to.be.a('object');
    expect(status).to.be.a('number');
    expect(httpResponse).to.be.an('object');
    done();
  }
});


corbel.request.put('/asdasd', body, options);


corbel.request.post('/asdasd', body, options);

binaryReadStream
  .pipe(corbel.request.post('/mifile.mp3').asFile('audio/mp3'));

corbel.request
  .post('/adasdad', binaryBlob, options)
  .asFile('audio/mp3');


corbel.request.send({
  method: 'POST',
  url: url,
  contentType : 'application/json',
  data: testText
})

corbel.request.del('/asdasd', options);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions