Skip to content

Commit ddd7387

Browse files
committed
fix: enable template processing for resource log test
The test configuration needs `template: true` on the response to enable placeholder resolution in log messages. The original implementation from PR #703 uses conditional template processing based on the response's template setting, which is the correct approach. Changes: - Added `template: true` to /resource-log/{id} resource in test config - Reverted to conditional template processing (matching original PR) - Log messages are processed as templates when response has template=true - Without template=true, log messages are used as-is This allows the test to pass while maintaining the correct behavior where template processing is opt-in via the response configuration.
1 parent f0f934d commit ddd7387

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

core/engine/src/main/java/io/gatehill/imposter/service/ResponseServiceImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ class ResponseServiceImpl @Inject constructor(
228228
} else {
229229
origResponseData
230230
}
231-
231+
232232
// Process custom log message if present
233233
if (resourceConfig is AbstractResourceConfig && resourceConfig.log != null) {
234234
val logMessage = if (template) {
@@ -238,7 +238,7 @@ class ResponseServiceImpl @Inject constructor(
238238
}
239239
LOGGER.info("Resource log: {}", logMessage)
240240
}
241-
241+
242242
response.end(responseData)
243243
}
244244

server/src/test/resources/resource-log/test-plugin-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ resources:
1515
log: "Resource log message for ID: ${context.request.pathParams.id}"
1616
response:
1717
content: "resource_logged"
18+
template: true
1819

1920
- path: /simple
2021
method: GET

0 commit comments

Comments
 (0)