Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>REST LensNew to Visual Studio Code? Get it now.
REST Lens

REST Lens

dtinth

|
707 installs
| (0) | Free
An advanced VS Code extension that calls HTTP endpoint when text matches a regular expression and displays the result as code lenses
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

rest-lens README

An advanced VS Code extension that calls HTTP endpoint when text matches a regular expression and displays the result as code lenses.

Features

Easily build programmable code lenses using just a simple JSON endpoint.

Given the VS Code settings:

  "restLens.providers": {
    "github": {
      "pattern": "https://github\\.com/[^/]+/[^/]+/(?:issues|pull)/\\d+",
      "url": "http://localhost:2323/info"
    }
  }

…and an endpoint (example here implemented with Node.js):

const express = require('express')
const app = express()
const got = require('got')
const metascraper = require('metascraper')([require('metascraper-title')()])
app.get('/info', async (req, res, next) => {
  try {
    const targetUrl = req.query.m[0]
    const { body: html, url } = await got(targetUrl)
    const metadata = await metascraper({ html, url })
    res.json({ title: metadata.title || url, url: targetUrl })
  } catch (error) {
    next(error)
  }
})
app.listen(+process.env.PORT || 2323)

This will display GitHub Issue and Pull Request titles as code lenses.

Screenshot

Extension Settings

This extension contributes the following settings:

  • restLens.providers An object of REST code lens providers, keyed by its ID. Each code lens provider will be an object with the following properties:

    • pattern The regular expression to match against the document.
    • url The URL to invoke

Overriding

If two REST code lens providers match at the same position, the shorter provider ID will override the longer provider ID iff the shorter one is a prefix of the longer one. For example, if providers github and github_private matches the same text, github_private overrides github.

HTTP Endpoint Specification

Request

The extension will make a GET request to the specified URL with the RegExp match as GET query parameter named m[].

  • m[0] The matched text
  • m[n] The capture group matches

Response

It should return a JSON object with the following properties:

  • title The title to display on the code lens
  • url The URL to open when clicking on the code lens
  • command+arguments The VS Code command to execute when clicking on the code lens, overriding url

The response will be cached throughout the session until the "Clear response cache" command is invoked.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft