Skip to content

Commit 1041e6d

Browse files
committed
updated website to add overridden forward requests
1 parent 371e42d commit 1041e6d

File tree

12 files changed

+260
-98
lines changed

12 files changed

+260
-98
lines changed

jekyll-www.mock-server.com/mock_server/_includes/creating_expectations.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ <h3>Actions</h3>
103103
<li><strong><a href="#forward_action">forward</a></strong> - forwards requests defined by using
104104
<ul>
105105
<li>the <strong><a href="#button_forward_exactly">exact request received</a></strong></li>
106+
<li>an <strong><a href="#button_forward_overridden">overridden request</a></strong></li>
106107
<li>a <strong><a href="#button_javascript_templated_forward">javascript template</a></strong></li>
107108
<li>a <strong><a href="#button_javascript_velocity_templated_forward">velocity template</a></strong></li>
108109
<li>a <strong><a href="#button_forward_class_callback">server side callback</a></strong> (via classpath)</li>
@@ -162,6 +163,9 @@ <h3>Actions</h3>
162163
<li><strong><a href="#button_forward_exactly_in_https">scheme</a></strong></li>
163164
</ul>
164165
</li>
166+
<li>
167+
<p>or an <a href="#button_forward_overridden">overridden request</a>, with a <strong><a href="#button_forward_overridden_with_delay">delay</a></strong>, that allows any element of requests to be overridden before they are forwarded</p>
168+
</li>
165169
<li>
166170
<p>or a templated forwarder using <strong><a href="#button_javascript_templated_forward">javascript</a></strong> or <strong><a href="#button_javascript_velocity_templated_forward">velocity</a></strong>, with a <strong><a href="#button_javascript_templated_forward_with_delay">delay</a></strong>, that allows requests to be modified or completely re-written before they are forwarded</p>
167171
</li>

jekyll-www.mock-server.com/mock_server/_includes/error_action_code_examples.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
</div>
4141
<button class="accordion inner">REST API</button>
4242
<div class="panel">
43-
<pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/expectation" -d '{
43+
<pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
4444
"httpRequest": {
4545
"path": "/some/path"
4646
},
@@ -86,7 +86,7 @@
8686
</div>
8787
<button class="accordion inner">REST API</button>
8888
<div class="panel">
89-
<pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/expectation" -d '{
89+
<pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
9090
"httpRequest" : {
9191
"path" : "/some/path"
9292
},

jekyll-www.mock-server.com/mock_server/_includes/forward_action_code_examples.html

Lines changed: 132 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
</div>
3838
<button class="accordion inner">REST API</button>
3939
<div class="panel">
40-
<pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/expectation" -d '{
40+
<pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
4141
"httpRequest": {
4242
"path": "/some/path"
4343
},
@@ -88,7 +88,7 @@
8888
</div>
8989
<button class="accordion inner">REST API</button>
9090
<div class="panel">
91-
<pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/expectation" -d '{
91+
<pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
9292
"httpRequest": {
9393
"path": "/some/path"
9494
},
@@ -100,6 +100,132 @@
100100
}'</code></pre>
101101
</div>
102102
</div>
103+
<button id="button_forward_overridden" class="accordion">forward overridden request</button>
104+
<div class="panel">
105+
<button class="accordion inner">Java</button>
106+
<div class="panel">
107+
<pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
108+
.when(
109+
request()
110+
.withPath("/some/path")
111+
)
112+
.forward(
113+
forwardOverriddenRequest(
114+
request()
115+
.withPath("/some/other/path")
116+
.withHeader("Host", "target.host.com")
117+
)
118+
);</code></pre>
119+
</div>
120+
<button class="accordion inner">JavaScript</button>
121+
<div class="panel">
122+
<pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
123+
mockServerClient("localhost", 1080).mockAnyResponse({
124+
"httpRequest": {
125+
"path": "/some/path"
126+
},
127+
"httpOverrideForwardedRequest": {
128+
"httpRequest": {
129+
"path": "/some/other/path",
130+
"headers": {
131+
"Host": ["target.host.com"]
132+
}
133+
}
134+
}
135+
}).then(
136+
function () {
137+
console.log("expectation created");
138+
},
139+
function (error) {
140+
console.log(error);
141+
}
142+
);</code></pre>
143+
</div>
144+
<button class="accordion inner">REST API</button>
145+
<div class="panel">
146+
<pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
147+
"httpRequest": {
148+
"path": "/some/path"
149+
},
150+
"httpOverrideForwardedRequest": {
151+
"httpRequest": {
152+
"path": "/some/other/path",
153+
"headers": {
154+
"Host": ["target.host.com"]
155+
}
156+
}
157+
}
158+
}'</code></pre>
159+
</div>
160+
</div>
161+
<button id="button_forward_overridden_with_delay" class="accordion">forward overridden request with delay</button>
162+
<div class="panel">
163+
<button class="accordion inner">Java</button>
164+
<div class="panel">
165+
<pre class="prettyprint lang-java code"><code class="code">new MockServerClient("localhost", 1080)
166+
.when(
167+
request()
168+
.withPath("/some/path")
169+
)
170+
.forward(
171+
forwardOverriddenRequest(
172+
request()
173+
.withHeader("Host", "target.host.com")
174+
.withBody("some_overridden_body")
175+
).withDelay(SECONDS, 10)
176+
);</code></pre>
177+
</div>
178+
<button class="accordion inner">JavaScript</button>
179+
<div class="panel">
180+
<pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
181+
mockServerClient("localhost", 1080).mockAnyResponse({
182+
"httpRequest": {
183+
"path": "/some/path"
184+
},
185+
"httpOverrideForwardedRequest": {
186+
"httpRequest": {
187+
"path": "/some/other/path",
188+
"body": "some_overridden_body",
189+
"headers": {
190+
"Host": ["target.host.com"]
191+
}
192+
},
193+
"delay": {
194+
"timeUnit": "SECONDS",
195+
"value": 10
196+
}
197+
}
198+
}).then(
199+
function () {
200+
console.log("expectation created");
201+
},
202+
function (error) {
203+
console.log(error);
204+
}
205+
);</code></pre>
206+
</div>
207+
<button class="accordion inner">REST API</button>
208+
<div class="panel">
209+
<pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
210+
"httpRequest": {
211+
"path": "/some/path"
212+
},
213+
"httpOverrideForwardedRequest": {
214+
"httpRequest": {
215+
"path": "/some/other/path",
216+
"body": "some_overridden_body",
217+
"headers": {
218+
"Host": ["target.host.com"]
219+
}
220+
},
221+
"delay": {
222+
"timeUnit": "SECONDS",
223+
"value": 10
224+
}
225+
}
226+
}'</code></pre>
227+
</div>
228+
</div>
103229
<button id="button_javascript_templated_forward" class="accordion">javascript templated forward</button>
104230
<div class="panel">
105231
<button class="accordion inner">Java</button>
@@ -160,7 +286,7 @@
160286
</div>
161287
<button class="accordion inner">REST API</button>
162288
<div class="panel">
163-
<pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/expectation" -d '{
289+
<pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
164290
"httpRequest": {
165291
"path": "/some/path"
166292
},
@@ -244,7 +370,7 @@
244370
</div>
245371
<button class="accordion inner">REST API</button>
246372
<div class="panel">
247-
<pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/expectation" -d '{
373+
<pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
248374
"httpRequest": {
249375
"path": "/some/path"
250376
},
@@ -333,7 +459,7 @@
333459
</div>
334460
<button class="accordion inner">REST API</button>
335461
<div class="panel">
336-
<pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/expectation" -d '{
462+
<pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
337463
"httpRequest": {
338464
"path": "/some/path"
339465
},
@@ -413,7 +539,7 @@
413539
</div>
414540
<button class="accordion inner">REST API</button>
415541
<div class="panel">
416-
<pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/expectation" -d '{
542+
<pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/expectation" -d '{
417543
"httpRequest" : {
418544
"path" : "/some.*"
419545
},

0 commit comments

Comments
 (0)