Skip to content

Commit

Permalink
Add more examples
Browse files Browse the repository at this point in the history
  • Loading branch information
vesln committed Nov 25, 2013
1 parent b92b524 commit aab6193
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 2 deletions.
47 changes: 45 additions & 2 deletions README.md
Expand Up @@ -63,14 +63,57 @@ api()

### Middlewares

```js
api()
.json()
.use(function(options, next) {
// modify the options for `request` here
next(options);
})
.get('https://api.github.com/users/vesln')
.end(function(err, res, body) {
if (err) throw err;
});
```

### Serializers and parsers

```js
var xml = require('my-xml-library');

api()
.serializer(function(params, fn) {
var err = new Error('Things went wrong');
var res = xml.objectToXml(params);
fn(err, res);
})
.parser(function(body, fn) {
var err = new Error('Things went wrong');
var res = xml.xmlToObject(body);
fn(err, res);
})
.get('https://api.github.com/users/vesln.xml')
.expectStatus(200)
.end(function(err, res, body) {
if (err) throw err;
});
```

### AssertionError configurations

Similar to Chai.js and other frameworks, you can enable `showDiff`.

```js
var hippie = require('hippie');
hippie.assert.showDiff = true;
```

![showDiff](http://i.imgur.com/hsR8Kbs.png)

### Authentication

### DRY

### Enable showDiff

## API

### #timeout
Expand Down
12 changes: 12 additions & 0 deletions examples/middlewares.js
@@ -0,0 +1,12 @@
var api = require('../');

api()
.json()
.use(function(options, next) {
// modify the options for `request` here
next(options);
})
.get('https://api.github.com/users/vesln')
.end(function(err, res, body) {
if (err) throw err;
});
19 changes: 19 additions & 0 deletions examples/serialize-parse.js
@@ -0,0 +1,19 @@
var api = require('../');
var xml = require('my-xml-library');

api()
.serializer(function(params, fn) {
var err = new Error('Things went wrong');
var res = xml.objectToXml(params);
fn(err, res);
})
.parser(function(body, fn) {
var err = new Error('Things went wrong');
var res = xml.xmlToObject(body);
fn(err, res);
})
.get('https://api.github.com/users/vesln.xml')
.expectStatus(200)
.end(function(err, res, body) {
if (err) throw err;
});

0 comments on commit aab6193

Please sign in to comment.