Skip to content
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

Extract method in PluginReader to handle missing plugin resource #6126

Merged
merged 1 commit into from
Sep 7, 2019
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
13 changes: 9 additions & 4 deletions packages/plugin-ext/src/hosted/node/plugin-reader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ export class HostedPluginReader implements BackendApplicationContribution {
@multiInject(MetadataProcessor) private readonly metadataProcessors: MetadataProcessor[];

/**
* Map between a plugin's id and the local storage
* Map between a plugin id and its local storage
*/
private pluginsIdsFiles: Map<string, string> = new Map();
protected pluginsIdsFiles: Map<string, string> = new Map();

configure(app: express.Application): void {
app.get('/hostedPlugin/:pluginId/:path(*)', (req, res) => {
app.get('/hostedPlugin/:pluginId/:path(*)', async (req, res) => {
const pluginId = req.params.pluginId;
const filePath = req.params.path;

Expand All @@ -67,11 +67,16 @@ export class HostedPluginReader implements BackendApplicationContribution {
}
});
} else {
res.status(404).send(`The plugin with id '${escape_html(pluginId)}' does not exist.`);
await this.handleMissingResource(req, res);
}
});
}

protected async handleMissingResource(req: express.Request, res: express.Response): Promise<void> {
const pluginId = req.params.pluginId;
res.status(404).send(`The plugin with id '${escape_html(pluginId)}' does not exist.`);
}

async getPluginMetadata(pluginPath: string): Promise<PluginMetadata | undefined> {
return this.doGetPluginMetadata(pluginPath);
}
Expand Down