Map Mock
Map Mock is the first-class feature of EchoProxy. It is designed with love🔥, very easy to learn and use. It helps to map & mock HTTP(s) request/response elegantly.
Entrance: Click left sidebar button

Map Rule
The first step is creating a new Map Rule by clicking the +Add button. There are two Map Rule Types:
Map Local: Map HTTP(s) request to a local file, where the response Header & Body will be parsed from.
Map Remote: Map HTTP(s) request to a new URL, where the response Header & Body will be fetched from.

Method:
GET/POST…: Rule matches when request method is exactly the same.
ANY: Rule matches for any request method.
Match Type
Equals: Rule matches when request URL is exactly the same.
Wildcard: Rule matches when request URL Wildcard matched.
Regex: Rule matches when request URL Regex matched.
Map Local
Map HTTP(s) request to a local file, where the response Header & Body will be parsed from. It won’t send HTTP(s) request to the original URL.
Let’s take an example to learn Map Local. Example URL https://demo.echolabx.com/. It’s default response:
Content-Type: text/plain; charset=utf-8
Content Body:Hi: EchoProxy
Create a Map Rule with following settings:
MapLocal, GET, Equals, Enabled ✅
URL:https://demo.echolabx.com/
Set the content of Response(Header+Body) as following:
HTTP/1.1 200 OKContent-Type: application/json; charset=UTF-8
{ "msg": "success"}

Visit the URL https://demo.echolabx.com/ again with refresh. You’ll see the response has been changed by Map Mock. New response is:
Content-Type: application/json; charset=UTF-8
Content Body:
{ "msg": "success"}
Map Remote
Map HTTP(s) request to a new URL, where the response Header & Body will be fetched from. It will send HTTP(s) requests to the new URL when set.
Let’s take an example. We want to map URL-1 to URL-2:
URL-1: https://demo.echolabx.com/json
URL-2: https://demo.echolabx.com/json-v2
Create a Map Rule with following settings:
MapRemote, GET, Equals, Enabled ✅
URL:https://demo.echolabx.com/json
Set EchoScript with the following content:
on_request := func(env, req) { return { url: "https://demo.echolabx.com/json-v2" }}

Visit the URL https://demo.echolabx.com/json again with refresh. You’ll see the response is the exactly same with URL-2.
Update the Map Rule with following settings:
MapRemote, GET, Wildcard, Enabled ✅
URL:https://demo.echolabx.com/json*
Set EchoScript with the following content:
on_request := func(env, req) { return { url: "https://demo.echolabx.com/json-v2" + req.u[1] }}

Visit the following URLs again with refresh. HTTP responses are changed to URL json-v2.
- https://demo.echolabx.com/json
- https://demo.echolabx.com/json?page=1
- https://demo.echolabx.com/json?age=30
Match Type
1. Wildcard
Rule matches when request URL Wildcard matched.
Only supports asterisk *.
The question ? mark is treated as an ordinary charater.
Wildcard Example A:
Wildcard: https://demo.echolabx.com/json*Request URL: https://demo.echolabx.com/json?page=5Rule Match: YESreq.u value: ["https://demo.echolabx.com/json?page=5", "?page=5"]
Wildcard Example B:
Wildcard: https://demo.echolabx.com/json?page=*Request URL: https://demo.echolabx.com/json?page=5&age=40Rule Match: YESreq.u value: ["https://demo.echolabx.com/json?page=5&age=40", "5&age=40"]
Wildcard Example C:
Wildcard: https://demo.echolabx.com/json?page=*&age=*Request URL: https://demo.echolabx.com/json?page=5&age=40Rule Match: YESreq.u value: ["https://demo.echolabx.com/json?page=5&age=40", "5", "40"]
Wildcard Example D:
Wildcard: https://demo.echolabx.com/json?page=?Request URL: https://demo.echolabx.com/json?page=5Rule Match: NO
2. Regex
Rule matches when request URL Regex matched. It uses Golang Regex Syntax. We recommend to use Wildcard most of the time. Regex is much more complex than Wildcard.
Regex Example A:
Regex: https://demo.echolabx.com/json(.*)Request URL: https://demo.echolabx.com/json?page=5Rule Match: YESreq.u value: ["https://demo.echolabx.com/json?page=5", "?page=5"]
Regex Example B:
Regex: https://demo.echolabx.com/json.*Request URL: https://demo.echolabx.com/json?page=5Rule Match: YESreq.u value: ["https://demo.echolabx.com/json?page=5"]
Regex Example C:
Regex: https://demo.echolabx.com/json\?page=([\d]+)&age=([\d]+)Request URL: https://demo.echolabx.com/json?page=5&age=30Rule Match: YESreq.u value: ["https://demo.echolabx.com/json?page=5&age=30", "5", "30"]