-
|
I have created a simple Service in Microcks which I want it to act like a proxy to redirect me when hit to an Express Server. I have tried to use the following 3 dispatchers available in the UI:
When I use the When I try the other 2 (by the way, I have enabled Postman runtime as well in the same docker-compose), nothing really happens:
sgkiokas@ATH-SDV-M088-GS ~ % curl -i -X POST "http://localhost:8080/rest/ExpressServer+Dispatcher/1/dispatch/paycord" -H "Content-Type: application/json" -d '{}'
HTTP/1.1 200
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, PUT, GET, OPTIONS, DELETE
Access-Control-Max-Age: 3600
Access-Control-Allow-Headers: content-length, host, content-type, user-agent, accept
X-Content-Type-Options: nosniff
X-XSS-Protection: 0
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
Content-Type: application/json;charset=UTF-8
Content-Length: 49
Date: Wed, 03 Dec 2025 13:54:50 GMT
{
"status": "callback received by dispatcher"
}%
14:11:59.823 INFO 1 --- [andler-528] i.github.microcks.web.RestController : Servicing mock response for service [ExpressServer+Dispatcher, 1] on uri /rest/ExpressServer+Dispatcher/1/dispatch/paycord with verb POST
{
"info": {
"name": "ExpressServer Dispatcher",
"_postman_id": "expressserver-dispatcher-001",
"description": "version=1 - Postman collection for Microcks to mock and dispatch to Express server.",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "POST /dispatch/paycord",
"request": {
"method": "POST",
"header": [
{ "key": "Content-Type", "value": "application/json" }
],
"body": {
"mode": "raw",
"raw": "{}"
},
"url": {
"raw": "{{base}}/dispatch/paycord",
"host": ["{{base}}"],
"path": ["dispatch", "paycord"]
}
},
"response": [
{
"name": "Ack",
"originalRequest": {
"method": "POST",
"header": [
{ "key": "Content-Type", "value": "application/json" }
],
"body": { "mode": "raw", "raw": "{}" },
"url": { "raw": "{{base}}/dispatch/paycord", "host": ["{{base}}"], "path": ["dispatch", "paycord"] }
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"body": "{\n \"status\": \"callback received by dispatcher\"\n}"
}
]
}
],
"variable": [
{ "key": "base", "value": "http://localhost:8080/rest/ExpressServer/1.0" }
]
}
function dispatch(request) {
const method = (request.method || 'POST').toUpperCase();
if (method !== 'POST') {
return { passthrough: true };
}
return {
forward: {
method: 'POST',
url: 'http://express-server:5000/dispatch/paycord',
headers: {
'Content-Type': 'application/json',
},
body: '{}',
},
};
}Connectivity wise, I have checked everything and the containers do talk to each other. I am using Maybe we need more examples of how to properly setup those dispatching rules at the docs? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
Hey @sgkiokas, We might actually lack some documentation... sorry. I'll try to give you some pointers and insights below.
|
Beta Was this translation helpful? Give feedback.
Hey @sgkiokas,
We might actually lack some documentation... sorry. I'll try to give you some pointers and insights below.
PROXYdispatcherHave you checked https://microcks.io/blog/new-proxy-features-1.9.1/?
Maybe the dispatcher rules have been badly specified... It should consist of just the base URL of the target endpoint. Exemple:
https://backend.acme.com- so when you callhttp://localhost:8080/rest/ExpressServer+Dispatcher/1/dispatch/paycordon Microcks, it is actually proxied tohttps://backend.acme.com/dispatch/paycord.Do not hesitate to share more logs from the Microcks container to see what's actually going wrong.
JSdispatcherT…