Skip to content

Commit

Permalink
✨ feat: rename to getPluginSettingsFromRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Sep 5, 2023
1 parent b4afc5e commit 3969457
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions docs/api/request.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: getPluginSettingsStringFromRequest
title: getPluginSettingsFromRequest
description: 从请求中获取插件设置字符串
group:
title: 服务端
Expand All @@ -12,7 +12,7 @@ nav: API
## 语法

```ts
const settings = getPluginSettingsStringFromRequest<T>(req: Request): T | undefined;
const settings = getPluginSettingsFromRequest<T>(req: Request): T | undefined;
```

## 参数
Expand All @@ -30,14 +30,14 @@ const settings = getPluginSettingsStringFromRequest<T>(req: Request): T | undefi
```ts
import {
createHeadersWithPluginSettings,
getPluginSettingsStringFromRequest,
getPluginSettingsFromRequest,
} from '@lobehub/chat-plugin-sdk';

const req = new Request('https://api.example.com', {
headers: createHeadersWithPluginSettings({ theme: 'dark' }),
});

const settings = getPluginSettingsStringFromRequest(req);
const settings = getPluginSettingsFromRequest(req);

console.log(settings); // 输出: { theme: "dark" }
```
Expand Down
2 changes: 1 addition & 1 deletion src/request.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const LOBE_PLUGIN_SETTINGS = 'X-LOBE_PLUGIN_SETTINGS';

export const getPluginSettingsStringFromRequest = <T = any>(req: Request): T | undefined => {
export const getPluginSettingsFromRequest = <T = any>(req: Request): T | undefined => {
const settings = req.headers.get(LOBE_PLUGIN_SETTINGS);
if (!settings) return;

Expand Down

0 comments on commit 3969457

Please sign in to comment.