Skip to content

Commit 2b9db51

Browse files
committed
update container host name
1 parent 51f5164 commit 2b9db51

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

localstack-wiremock/localstack_wiremock/extension.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ class WireMockExtension(ProxiedDockerContainerExtension):
77
HOST = "wiremock.<domain>"
88
# name of the Docker image to spin up
99
DOCKER_IMAGE = "wiremock/wiremock"
10+
# name of the container
11+
CONTAINER_NAME = "ls-wiremock"
1012

1113
def __init__(self):
1214
super().__init__(
1315
image_name=self.DOCKER_IMAGE,
1416
container_ports=[8080],
17+
container_name=self.CONTAINER_NAME,
1518
host=self.HOST,
1619
)

localstack-wiremock/sample-app/src/handler.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ def get_time_off(event, context):
88
and returns a transformed JSON response.
99
"""
1010
try:
11-
# Define the mock API endpoint URL (hardcoding `host.docker.internal` for now)
12-
# url = "http://wiremock.localhost.localstack.cloud:8080/company/time-offs/534813865"
13-
url = "http://host.docker.internal:8080/company/time-offs/534813865"
11+
# Define the mock API endpoint URL (hardcoding `wiremock.localhost.localstack.cloud` for
12+
# local dev for now - could be injected via env variables in the future ...)
13+
url = "http://wiremock.localhost.localstack.cloud:4566/company/time-offs/534813865"
1414

1515
# Make a GET request to the mock API
1616
response = requests.get(url, timeout=5)
@@ -41,6 +41,7 @@ def get_time_off(event, context):
4141
"message": "Could not connect to the downstream HR service.",
4242
"error": str(e),
4343
}
44+
print("Error:", error_message)
4445
return {
4546
"statusCode": 503, # Service Unavailable
4647
"headers": {"Content-Type": "application/json"},
@@ -49,6 +50,7 @@ def get_time_off(event, context):
4950
except Exception as e:
5051
# Handle other unexpected errors (e.g., JSON parsing issues, programming errors)
5152
error_message = {"message": "An unexpected error occurred.", "error": str(e)}
53+
print("Error:", error_message)
5254
return {
5355
"statusCode": 500, # Internal Server Error
5456
"headers": {"Content-Type": "application/json"},

0 commit comments

Comments
 (0)