Skip to content

Commit 264868d

Browse files
Merge pull request #139 from microsoftgraph/Middleware_Options
Implementation of Middleware Options
2 parents 1ccd751 + 8419b88 commit 264868d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+701
-2184
lines changed

.vscode/launch.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@
3535
"${workspaceRoot}/spec/development/workload/*.js"
3636
],
3737
"cwd": "${workspaceRoot}",
38+
"preLaunchTask": "Run Build",
39+
"outFiles": [],
40+
"internalConsoleOptions": "openOnSessionStart"
41+
},
42+
{
43+
"type": "node",
44+
"request": "launch",
45+
"name": "Run middleware tests",
46+
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
47+
"args": [
48+
"${workspaceRoot}/spec/middleware/*.js"
49+
],
50+
"cwd": "${workspaceRoot}",
51+
"preLaunchTask": "Run Build",
3852
"outFiles": [],
3953
"internalConsoleOptions": "openOnSessionStart"
4054
}

docs/CustomMiddlewareChain.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ As name suggests it comes in middle of something and that is request and respons
88

99
### Implement Middlewares
1010

11-
Create a custom middleware pipeline by implementing the [Middleware](../src/IMiddleware.ts) interface. The following examples demonstrate how to create a custom logging middleware and how to create a custom http request a response handler.
11+
Create a custom middleware pipeline by implementing the [Middleware](../src/middleware/IMiddleware.ts) interface. The following examples demonstrate how to create a custom logging middleware and how to create a custom http request a response handler.
1212

1313
First middleware is passed with the context object containing request, and other middleware specific options. One has to explicitly make call to execute method of the next middleware with context object once the current middleware work is over.
1414

@@ -146,4 +146,4 @@ export class MyLoggingHandler implements Middleware {
146146
}
147147
```
148148

149-
Refer [MiddlewareOptions](../src/IMiddlewareOptions.ts) interface to know its structure.
149+
Refer [MiddlewareOptions](../src/middleware/option/IMiddlewareOption.ts) interface to know its structure.

docs/OtherAPIs.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,21 @@ try {
7474
}
7575
```
7676

77+
## MIDDLEWAREOPTIONS
78+
79+
You can override the client middleware behavior by setting per request middleware options. Use the `.middlewareOptions()` request builder method to add custom middleware behavior for a specific request. The `middlewareOptions()` method takes an array of strongly typed middleware options. These middleware options are an implementation of the [MiddlewareOption](../src/middleware/option/IMiddlewareOption.ts) interface.
80+
81+
```typescript
82+
try {
83+
let res = await client.api("/me/messages").middlewareOptions([
84+
new RetryHandlerOption(5000)
85+
]).get();
86+
console.log(res);
87+
} catch (error) {
88+
throw error;
89+
}
90+
```
91+
7792
## RESPONSETYPE
7893

7994
To set a custom response type, use the`.responseType(<ResponseType>)` method. Refer [ResponseType.ts](./src/ResponseType.ts) for available options.
@@ -85,4 +100,4 @@ try {
85100
} catch (error) {
86101
throw error;
87102
}
88-
````
103+
````

0 commit comments

Comments
 (0)