Skip to content

Commit

Permalink
Extract method in PluginReader to handle missing plugin resource
Browse files Browse the repository at this point in the history
Signed-off-by: Mykola Morhun <[email protected]>
  • Loading branch information
mmorhun authored and akosyakov committed Sep 7, 2019
1 parent 263349a commit 4dd24dc
Showing 1 changed file with 9 additions and 4 deletions.
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

0 comments on commit 4dd24dc

Please sign in to comment.