Scaffolder: HTTP Requests logo

Backstage HTTP request scaffolder actions

Create HTTP requests with the scaffolder

Created by Roadie

Set up Backstage in minutes with Roadie

Installation steps

Install the plugin into your scaffolded Backstage application.

cd packages/backend
yarn add @roadiehq/scaffolder-backend-module-http-request

Add http request actions to your scaffolder backend

// packages/backend/src/plugins/scaffolder.ts

const actions = [
  createHttpBackstageAction({ config }),
  ...createBuiltinActions({
    containerRunner,
    integrations,
    config,
    catalogClient,
    reader,
  }),
];

return await createRouter({
  containerRunner,
  logger,
  config,
  database,
  catalogClient,
  reader,
  actions,
});

Create template with http actions

...
  steps:
    - id: backstage_request
      name: backstage request
      action: http:backstage:request
      input:
        method: 'GET'
        path: '/proxy/snyk/org/<some-org>/project/<some-project-id>/aggregated-issues'
        headers:
          test: 'hello'
          foo: 'bar'
        params:
          name: 'test'
          bar: 'foo'

    - id: backstage_request_with_input
      name: backstage request
      action: http:backstage:request
      input:
        method: 'POST'
        path: '/proxy/snyk/org/<some-org>/project/<some-project-id>/aggregated-issues/get/some/job{{ steps["backstage_request"].output.body.number }}'
        headers:
            test: 'hello'
            foo: 'bar'
        body:
            name: 'test'
            bar: 'foo'

  output:
    getResponse: '{{ steps["backstage_request_with_input"].output.body }}'
    getCode: '{{ steps["backstage_request_with_input"].output.code }}'
    getHeaders: '{{ steps["backstage_request_with_input"].output.headers }}'
...

Found a mistake? Update these instructions.

Things to know

This scaffolder action is meant to be used in a scaffolded Backstage application created by Backstage CLI. If you are using it in a Backstage monorepo, you need to modify the build process to transpile node_modules also.

NB: The path should always point to a proxy entry with the following format: proxy/<proxy-path>/<external-api-path>. i.e.: /proxy/snyk/org/<some-org>/projects or /proxy/circleci/api/projects (the CircleCI proxy path is circleci/api/ but Snyk is just snyk/)

Set up Backstage in minutes with Roadie