Skip to content

Commit

Permalink
Make request.middleware a public property
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed May 8, 2016
1 parent d9641b7 commit a850a6d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default class Request extends Base implements Promise<Response> {
body: any
options: any
transport: TransportOptions
middleware: Middleware[] = []

opened = false
aborted = false
Expand All @@ -57,7 +58,6 @@ export default class Request extends Base implements Promise<Response> {
private _downloadedBytes: number = null

_raw: any
_use: Middleware[] = []
_progress: ProgressFunction[] = []

private _promise: Promise<Response>
Expand All @@ -81,7 +81,7 @@ export default class Request extends Base implements Promise<Response> {
// External promise representation, resolves _after_ middleware.
this._promise = new Promise((resolve) => {
process.nextTick(() => {
const handle = compose(this._use)
const handle = compose(this.middleware)

const cb = () => {
this._handle()
Expand Down Expand Up @@ -127,7 +127,7 @@ export default class Request extends Base implements Promise<Response> {
transport: this.transport,
timeout: this.timeout,
rawHeaders: this.rawHeaders,
use: this._use,
use: this.middleware,
progress: this._progress
}
}
Expand All @@ -149,7 +149,7 @@ export default class Request extends Base implements Promise<Response> {

use (fns: Middleware | Middleware[]) {
for (const fn of arrify(fns)) {
this._use.push(fn)
this.middleware.push(fn)
}

return this
Expand Down

0 comments on commit a850a6d

Please sign in to comment.