Skip to content

Commit e2b0b55

Browse files
committed
✨ feat: support getPluginSettingsFromHeaders
1 parent 6199425 commit e2b0b55

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/request.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ export const getPluginSettingsFromRequest = <T = any>(req: Request): T | undefin
1111
}
1212
};
1313

14+
export const getPluginSettingsFromHeaders = <T = any>(headers: HeadersInit): T | undefined => {
15+
const header = new Headers(headers as any);
16+
17+
const settings = header.get(LOBE_PLUGIN_SETTINGS);
18+
if (!settings) return;
19+
20+
try {
21+
return JSON.parse(settings);
22+
} catch {
23+
return settings as any;
24+
}
25+
};
26+
1427
export const createHeadersWithPluginSettings = (
1528
settings: any,
1629
header?: HeadersInit,

0 commit comments

Comments
 (0)