-
Notifications
You must be signed in to change notification settings - Fork 0
Setting Up Proxy
Sam edited this page Sep 6, 2016
·
3 revisions
We saw how easy it is to setup a json api endpoint already in the previous page with a settings.json content like this
{
"config": [{
"apiport": 8891,
"datasource": [{
"mydata": [{
"hey": "whatpp"
}]
}],
"routes": [{
"route": "/api/GetProducts3",
"data": "mydata"
}]
}]
}
Now we have, in doing so, specified that when we hit http://localhost:8891/api/GetProducts3, the json data
[{
"hey": "whatpp"
}]
will be returned
Some times you need certain specific endpoints to call out to an existing external api, e.g
https://api.github.com/users/octocat
The settings.json becomes
{
"config": [{
"apiport": 8891,
"routes": [
{
"route": "/octocat",
"endpoint": "https://api.github.com/users/octocat"
}]
}]
} So that if you hit localhost:8891/octocat , you get data returned as if you had hit https://api.github.com/users/octocat
And if you still want the previous settings we had hitherto to apply as well along side, settings.json will look like this
{
"config": [{
"apiport": 8891,
"datasource": [{
"mydata": [{
"hey": "whatpp"
}]
}],
"routes": [{
"route": "/api/GetProducts3",
"data": "mydata"
},
{
"route": "/octocat",
"endpoint": "https://api.github.com/users/octocat"
}]
}]
}
Next >> https://github.com/getbackender/backender/wiki/TODO---Documentations-coming-up