From 918e2be318282d21fb8bea5bb9ed476e6ce0fa28 Mon Sep 17 00:00:00 2001 From: Himanshu Mishra Date: Mon, 5 Jul 2021 10:42:56 +0200 Subject: [PATCH] docs: Add an example code block for debugging new url reader Signed-off-by: Himanshu Mishra --- docs/integrations/url-reader.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/integrations/url-reader.md b/docs/integrations/url-reader.md index c37549cf8b..a2108d5c71 100644 --- a/docs/integrations/url-reader.md +++ b/docs/integrations/url-reader.md @@ -242,6 +242,23 @@ HTTP headers. When debugging one of the URL Readers, you can straightforward use the [`reader` instance created](https://github.com/backstage/backstage/blob/ebbe91dbe79038a61d35cf6ed2d96e0e0d5a15f3/packages/backend/src/index.ts#L57) when the backend starts and call one of the methods with your debugging URL. + +```ts +// File: packages/backend/src/index.ts + +async function main() { + // ... + const createEnv = makeCreateEnv(config); + + const testReader = createEnv('test-url-reader').reader; + const response = await testReader.readUrl( + 'https://github.com/backstage/backstage/blob/master/catalog-info.yaml', + ); + console.log((await response.buffer()).toString()); + // ... +} +``` + This will be run every time you restart the backend. Note that after any change in the URL Reader code, you need to kill the backend and restart, since the `reader` instance is memoized and does not update on hot module reloading. Also,