Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
doc: back to top
Browse files Browse the repository at this point in the history
  • Loading branch information
skenqbx committed Apr 22, 2015
1 parent 67564e9 commit 7341e7f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
10 changes: 10 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ RAIL.call('https://www.github.com/skenqbx/rail', function(response) {
}).end();
```

[back to top](#table-of-contents)

### globalClient - URL & plugin options

```js
Expand All @@ -66,6 +68,8 @@ RAIL.call({
}).end();
```

[back to top](#table-of-contents)

### globalClient - request & plugin options

```js
Expand All @@ -82,6 +86,8 @@ RAIL.call({
}).end();
```

[back to top](#table-of-contents)

### Custom client

```js
Expand Down Expand Up @@ -126,6 +132,8 @@ call.write('hello');
call.end('world');
```

[back to top](#table-of-contents)

## Tests

```bash
Expand All @@ -141,3 +149,5 @@ Branches : 79.64% ( 223/280 )
Functions : 83.93% ( 47/56 )
Lines : 85.99% ( 399/464 )
```

[back to top](#table-of-contents)
6 changes: 4 additions & 2 deletions doc/api.markdown
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# [RAIL](../README.markdown) API

## Static Exports

### RAIL.plugins
An object holding all built-in [plugins](./doc/plugins.markdown).

Expand Down Expand Up @@ -51,6 +49,8 @@ When `opt_options` is a string, it is handled like `opt_options.url`.

_Note: For convenience & compatibility with node core API, all request options can also be provided directly besides proto & plugin options._

[back to top](#railplugins)

## Class: Call
`Call` extends `stream.Writable`.

Expand Down Expand Up @@ -86,3 +86,5 @@ Always returns `this`.
`function({string} plugin, {string} status, {?string} opt_message)`

### Event 'error'

[back to top](#railplugins)
8 changes: 8 additions & 0 deletions doc/plugin-api.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ function myPlugin(rail, opt_options) {
module.exports = myPlugin;
```

[back to top](#table-of-contents)

## RAIL Plugin Events

These events are emitted on the `RAIL` object.
Expand Down Expand Up @@ -70,6 +72,8 @@ Emitted when response headers have been received.

`function({Call} call, {Object} options, {Response} response)`

[back to top](#table-of-contents)

## Interceptable Events
Specific events emitted on the `Call` object can be intercepted.
These _interceptable events_ are designed to gain complete control over the request workflow and allow implementing even non-trivial & asynchronous features as a plugin.
Expand All @@ -96,6 +100,8 @@ Emitted after the response headers have been received.
### Event: 'error'
Emitted on an error in context of a request.

[back to top](#table-of-contents)

## Request Management
All request configurations are stored in `call._stack`, the current configuration is referenced by `call._pointer`.

Expand All @@ -113,3 +119,5 @@ Returns `true` on success or when buffering is already enabled, `false` otherwis
Create a request object when no request is pending and a configuration is available. When no configuration is available, a _non-interceptable_ error is emitted.

Returns `true` when a request is pending, the newly created `request` object otherwise.

[back to top](#table-of-contents)
8 changes: 8 additions & 0 deletions doc/plugins.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ When the body is empty its value is `null`, otherwise a `Buffer`.
### buffer.intercept(call)
Manually intercept (buffer the response body). To be used by other plugins.

[back to top](#table-of-contents)

## cookies
Get/Set cookies. Received cookies are exported as `response.cookies`.

Expand All @@ -35,6 +37,8 @@ Get/Set cookies. Received cookies are exported as `response.cookies`.

- `{boolean} cookies` When `false`, the plugin is disabled for this _call_

[back to top](#table-of-contents)

## json
Parse response body. Parsed body is exported as `response.json`.

Expand All @@ -49,6 +53,8 @@ Uses the `buffer` plugin.

- `{boolean} json` enable json parsing

[back to top](#table-of-contents)

## redirect

**options**
Expand All @@ -70,3 +76,5 @@ Uses the `buffer` plugin.
### Event: 'redirect'

`function({Object} options)`

[back to top](#table-of-contents)

0 comments on commit 7341e7f

Please sign in to comment.