Skip to content

Commit

Permalink
✨ feat: support getPluginSettingsFromHeaders
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Dec 13, 2023
1 parent 6199425 commit e2b0b55
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ export const getPluginSettingsFromRequest = <T = any>(req: Request): T | undefin
}
};

export const getPluginSettingsFromHeaders = <T = any>(headers: HeadersInit): T | undefined => {
const header = new Headers(headers as any);

const settings = header.get(LOBE_PLUGIN_SETTINGS);
if (!settings) return;

try {
return JSON.parse(settings);
} catch {
return settings as any;
}
};

export const createHeadersWithPluginSettings = (
settings: any,
header?: HeadersInit,
Expand Down

0 comments on commit e2b0b55

Please sign in to comment.