Document VS Code endpoints

This commit is contained in:
Asher 2020-11-03 16:30:45 -06:00
parent e5c8e0aad1
commit 210fc049c4
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A
2 changed files with 13 additions and 0 deletions

View File

@ -32,6 +32,9 @@ router.get("/(:commit)(/*)?", async (req, res) => {
res.header("Cache-Control", "public, max-age=31536000") res.header("Cache-Control", "public, max-age=31536000")
} }
/**
* Used by VS Code to load extensions into the web worker.
*/
const tar = Array.isArray(req.query.tar) ? req.query.tar[0] : req.query.tar const tar = Array.isArray(req.query.tar) ? req.query.tar[0] : req.query.tar
if (typeof tar === "string") { if (typeof tar === "string") {
let stream: Readable = tarFs.pack(pathToFsPath(tar)) let stream: Readable = tarFs.pack(pathToFsPath(tar))

View File

@ -71,6 +71,9 @@ router.ws("/", async (socket, _, req) => {
await vscode.sendWebsocket(socket, req.query) await vscode.sendWebsocket(socket, req.query)
}) })
/**
* TODO: Might currently be unused.
*/
router.get("/resource(/*)?", async (req, res) => { router.get("/resource(/*)?", async (req, res) => {
ensureAuthenticated(req) ensureAuthenticated(req)
if (typeof req.query.path === "string") { if (typeof req.query.path === "string") {
@ -79,6 +82,9 @@ router.get("/resource(/*)?", async (req, res) => {
} }
}) })
/**
* Used by VS Code to load files.
*/
router.get("/vscode-remote-resource(/*)?", async (req, res) => { router.get("/vscode-remote-resource(/*)?", async (req, res) => {
ensureAuthenticated(req) ensureAuthenticated(req)
if (typeof req.query.path === "string") { if (typeof req.query.path === "string") {
@ -87,6 +93,10 @@ router.get("/vscode-remote-resource(/*)?", async (req, res) => {
} }
}) })
/**
* VS Code webviews use these paths to load files and to load webview assets
* like HTML and JavaScript.
*/
router.get("/webview/*", async (req, res) => { router.get("/webview/*", async (req, res) => {
ensureAuthenticated(req) ensureAuthenticated(req)
res.set("Content-Type", getMediaMime(req.path)) res.set("Content-Type", getMediaMime(req.path))