Hi all, I understand that if I want to export 2 API calls to differences endpoints i need to use Virtual but i didn’t success, I need your help please, for now all works for me when TYK get 1 api call and export 1 api call.
my code:
1) setting json:
{
"name": "SonoraTyk API",
"api_id": "sonora",
"org_id": "default",
"definition": {
"location": "header",
"key": "version"
},
"use_keyless": true,
"auth": {
"use_certificate": false,
"auth_header_name": ""
},
"upstream_certificates" : {
"edi.nedbankuat.absolutesys.com:9411" : "/opt/tyk-gateway/certs/Lancet_BTIS_UAT.pem"
},
"enable_coprocess_auth": false,
"log_level": "debug",
"enable_analytics": true,
"analytics_config": {
"enable_detailed_recording": true,
"type": "csv",
"csv_dir": "./tmp",
"purge_delay": 10
},
"response_processors": [
{
"name": "response_body_transform",
"options": {}
},
{
"name": "header_injector"
}
] ,
"event_handlers": {},
"custom_middleware": {
"pre": [
{
"name": "testJSVMData",
"path": "middleware/injectHeaderSonora.js",
"require_session": true
}
]
},
"version_data": {
"not_versioned": true,
"versions": {
"Default": {
"name": "Default",
"use_extended_paths": true,
"paths": {
"ignored": [],
"white_list": [],
"black_list": []
},
"extended_paths": {
"transform": [
{
"path": "/",
"method": "POST",
"template_data": {
"template_mode": "file",
"template_source": "./templates/SonoraRequestComment.tmpl",
"input_type": "json",
"enable_session": true
}
}
],
"transform_response": [
{
"path": "/*",
"method": "POST",
"template_data": {
"template_mode": "file",
"template_source": "./templates/SonoraRequestComment.tmpl",
"input_type": "json",
"enable_session": true
}
}
],
"transform_response_headers": [
{
"delete_headers": ["Content-Type"],
"add_headers": {"Content-Type": "application/json"},
"path": "/*",
"method": "POST"
}
]
}
}
}
},
"driver": "otto",
"proxy": {
"listen_path": "/SonoraTyk",
"target_url": "http://host.docker.internal:3030",
"strip_listen_path": true,
"transport":{
"ssl_insecure_skip_verify": false,
"ssl_force_common_name_check": true
}
}
}
2) middleware
var testJSVMData = new TykJS.TykMiddleware.NewMiddleware({});
function ContentType(){
return "text/json; charset=utf-8";
}
testJSVMData.NewProcessRequest(function(request, session, config) {
log(JSON.stringify(request.Headers));
log(JSON.stringify(request.Body));
//log(JSON.stringify(request));
log(typeof(request.Body));
request.SetHeaders["Content-Type"] = ContentType();
return testJSVMData.ReturnData(request, {});
});
3)tmpl file
{
"samplesDbResult": [
{
"orderName":"",
"slides": [
{
"slideNum": 3,
"blockNum": 2,
"slideLabel": "",
"comments":[
{
"content":"this is the link",
"type":"LINK"
}
]
}
]
}
]
}