Skip to content

Commit

Permalink
Merge pull request #978 from inversify/fix950
Browse files Browse the repository at this point in the history
Update middleware.md
  • Loading branch information
dcavanagh authored Oct 17, 2018
2 parents a47cdb0 + 35a0d35 commit 1a21c3f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions wiki/middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ to identify problems during the development process.
```ts
import { interfaces, Container } from "inversify";

function logger(planAndResolve: interfaces.PlanAndResolve<any>): interfaces.PlanAndResolve<any> {
return (args: interfaces.PlanAndResolveArgs) => {
function logger(planAndResolve: interfaces.Next): interfaces.Next {
return (args: interfaces.NextArgs) => {
let start = new Date().getTime();
let result = planAndResolve(args);
let end = new Date().getTime();
console.log(end - start);
console.log(`wooooo ${end - start}`);
return result;
};
}
Expand Down Expand Up @@ -76,8 +76,8 @@ In some cases you may want to intercept the resolution plan.
The default `contextInterceptor` is passed to the middleware as an property of `args`.

```ts
function middleware1(planAndResolve: PlanAndResolve<any>): PlanAndResolve<any> {
return (args: PlanAndResolveArgs) => {
function middleware1(planAndResolve: interfaces.Next): interfaces.Next<any> {
return (args: interfaces.NextArgs) => {
// args.nextContextInterceptor
// ...
};
Expand All @@ -87,8 +87,8 @@ function middleware1(planAndResolve: PlanAndResolve<any>): PlanAndResolve<any> {
You can extend the default `contextInterceptor` using a function:

```ts
function middleware1(planAndResolve: PlanAndResolve<any>): PlanAndResolve<any> {
return (args: PlanAndResolveArgs) => {
function middleware1(planAndResolve: interfaces.Next<any>): interfaces.Next<any> {
return (args: interfaces.NextArgs) => {
let nextContextInterceptor = args.contextInterceptor;
args.contextInterceptor = (context: interfaces.Context) => {
console.log(context);
Expand Down

0 comments on commit 1a21c3f

Please sign in to comment.