Skip to content

Commit d4362bb

Browse files
committed
Add handler for upcoming Lambda URI
1 parent cdf1c2d commit d4362bb

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

packages/core/src/lambda/activation.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { liveTailRegistry, liveTailCodeLensProvider } from '../awsService/cloudW
2424
import { getFunctionLogGroupName } from '../awsService/cloudWatchLogs/activation'
2525
import { ToolkitError, isError } from '../shared/errors'
2626
import { LogStreamFilterResponse } from '../awsService/cloudWatchLogs/wizard/liveTailLogStreamSubmenu'
27+
import { registerLambdaUriHandler } from './uriHandlers'
2728

2829
/**
2930
* Activates Lambda components.
@@ -116,6 +117,8 @@ export async function activate(context: ExtContext): Promise<void> {
116117
throw err
117118
}
118119
}
119-
})
120+
}),
121+
122+
registerLambdaUriHandler()
120123
)
121124
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
import * as vscode from 'vscode'
7+
import * as nls from 'vscode-nls'
8+
9+
import { SearchParams } from '../shared/vscode/uriHandler'
10+
import { showMessage } from '../shared/utilities/messages'
11+
import globals from '../shared/extensionGlobals'
12+
13+
const localize = nls.loadMessageBundle()
14+
15+
export function registerLambdaUriHandler() {
16+
async function openFunctionHandler(params: ReturnType<typeof parseOpenParams>) {
17+
await showMessage(
18+
'warn',
19+
localize(
20+
'AWS.lambda.uriUnavailable',
21+
'The URI handler you are attempting to open is not handled in this version of the toolkit, try installing the latest version'
22+
)
23+
)
24+
}
25+
26+
return vscode.Disposable.from(
27+
globals.uriHandler.onPath('/lambda/load-function', openFunctionHandler, parseOpenParams)
28+
)
29+
}
30+
function parseOpenParams(query: SearchParams) {
31+
return {
32+
functionName: query.getOrThrow(
33+
'functionName',
34+
localize('AWS.lambda.open.missingName', 'A function name must be provided')
35+
),
36+
region: query.getOrThrow('region', localize('AWS.lambda.open.missingRegion', 'A region must be provided')),
37+
isCfn: query.get('isCfn'),
38+
}
39+
}

0 commit comments

Comments
 (0)