Skip to content

feat: default middleware documentation #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion OpenAPI/kiota/middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Learn about implementing middleware into Kiota.
author: baywet
ms.author: vibiret
ms.topic: overview
ms.date: 11/21/2023
ms.date: 11/21/2024
---

# Implementing middleware
Expand Down Expand Up @@ -54,3 +54,32 @@ var httpClient = new HttpClient(httpMessageHandler!);
var adapter = new HttpClientRequestAdapter(authProvider, httpClient:httpClient);
var client = new PostsClient(adapter); // the name of the client will vary based on your generation parameters
```

## Middleware handlers

The following table describes which middleware handlers are implemented by the HTTP package, and which ones are included by default with any new request adapter.

| Name | Description | C# Support | Go Support | Java Support | TypeScript Support | PHP Support | Python Support |
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
| Authorization | Adds an access token to the request when using a native HTTP client. | Yes | No | Yes | No | No | No |
| Body Inspection | Allows the client application to inspect the request and response body through the associated options. | No | No | No | No | No | No |
| Chaos | For testing purposes only. Randomly fails requests to allow testing clients' resilience. | Yes | Yes | Yes | Yes | Yes | No |
| Headers Inspection | Allows the client application to inspect the request and response headers through the associated options. | Default | Default | Default | Default | Default | Default |
| Parameters Name Decoding | Decodes query parameter names that were encoded when building the URL because they contained characters not allowed by RFC 6570. | Default | Default | Default | Default | Default | Default |
| Redirect | Automatically follows Location response headers when a **301** or **302** response status code is received. | Default | Default | Default | Default | Default | Default |
| Request Compression | Compresses request bodies and retries requests without compression when a **415** response status code is received. | No | Default | No | Default | No | No |
| Response Decompression | Adds an **Accept-Encoding** request header and decompresses any response body with a **Content-Encoding** response header. | N/A | N/A | N/A | N/A | N/A | N/A |
| Retry | Automatically retries requests when a **429** or a **503** response status code is received. | Default | Default | Default | Default | Default | Default |
| Sunset | Logs a warning message with Open Telemetry upon receiving a **Sunset** response header. | No | No | No | No | No | No |
| Telemetry | Adds an extension point to augment the request with telemetry headers. | Yes | No | No | Yes | Yes | No |
| Uri Replacement | Enables replacement of segments of the request URI before it's sent out. | Default | Yes | Default | Yes | Yes | Default |
| User Agent | Adds the kiota http library version to the user agent request header. | Default | Default | Default | Default | Default | Default |

> [!NOTE]
> Languages with **N/A** in the response decompression column leverage the native response decompression offered by the HTTP client instead.

> [!NOTE]
> Languages with **Default** for the handler support value include the handler by default when creating the request adapter with no additional configuration.

> [!NOTE]
> Request body decompression is not enabled by default in ASP.NET Core APIs and needs to be enabled. Find out how to enable it with [Request Decompression in ASP.NET core](/aspnet/core/fundamentals/middleware/request-decompression).