Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix greedy path for proxy #1030

Merged
merged 2 commits into from Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/events/http/HttpServer.js
Expand Up @@ -857,26 +857,24 @@ export default class HttpServer {
serverlessLog('Routes defined in resources:')

Object.entries(resourceRoutes).forEach(([methodId, resourceRoutesObj]) => {
const {
isProxy,
method,
path,
pathResource,
proxyUri,
} = resourceRoutesObj
const { isProxy, method, pathResource, proxyUri } = resourceRoutesObj

if (!isProxy) {
serverlessLog(
`WARNING: Only HTTP_PROXY is supported. Path '${pathResource}' is ignored.`,
)
return
}
if (!path) {
if (!pathResource) {
serverlessLog(`WARNING: Could not resolve path for '${methodId}'.`)
return
}

const hapiPath = generateHapiPath(path, this.#options, this.#serverless)
const hapiPath = generateHapiPath(
pathResource,
this.#options,
this.#serverless,
)
const proxyUriOverwrite = resourceRoutesOptions[methodId] || {}
const proxyUriInUse = proxyUriOverwrite.Uri || proxyUri

Expand Down
7 changes: 0 additions & 7 deletions src/events/http/parseResources.js
Expand Up @@ -145,10 +145,6 @@ function getIntegrationObj(methodObj) {
return methodObj.Properties.Integration
}

function templatePathToHapiPath(path) {
return path.replace('+', '')
}

function constructHapiInterface(pathObjects, methodObjects, methodId) {
// returns all info necessary so that routes can be added in index.js
const methodObj = methodObjects[methodId]
Expand All @@ -163,16 +159,13 @@ function constructHapiInterface(pathObjects, methodObjects, methodId) {
return {}
}

const path = templatePathToHapiPath(pathResource)

if (Integration.Type === APIGATEWAY_INTEGRATION_TYPE_HTTP_PROXY) {
proxyUri = Integration.Uri
}

return {
isProxy: !!proxyUri,
method,
path,
pathResource,
proxyUri,
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/generateHapiPath.js
Expand Up @@ -4,7 +4,7 @@ export default function generateHapiPath(path = '', options, serverless) {

if (!options.noPrependStageInUrl) {
const stage = options.stage || serverless.service.provider.stage
// prepend stage to path
// prepend the stage to path
hapiPath = `/${stage}${hapiPath}`
}

Expand Down