#!/usr/bin/env bash
# Return a response generated by a Velocity template.
# Assumes MOCKSERVER_URL is set (defaults to http://localhost:1080).

curl -X PUT "${MOCKSERVER_URL:-http://localhost:1080}/mockserver/expectation" \
-d '{
  "httpRequest": {
    "path": "/some/path"
  },
  "httpResponseTemplate": {
    "template": "{\"statusCode\": 200,\"cookies\": {\"session\": \"$!request.headers['\''Session-Id'\''][0]\" },\"headers\": {\"Client-User-Agent\": [ \"$!request.headers['\''User-Agent'\''][0]\" ] },\"body\": $!request.body}",
    "templateType": "VELOCITY"
  }
}'
