mirror of https://github.com/BTCPrivate/z-nomp.git
Update api.js
Set `Content-Type: application/json` on api requests. This may help with browser compatibility and also allows browsers to render the json visually when directly browsing the api.
This commit is contained in:
parent
5e1301406e
commit
e2af3372dd
|
@ -15,9 +15,11 @@ module.exports = function(logger, portalConfig, poolConfigs){
|
||||||
|
|
||||||
switch(req.params.method){
|
switch(req.params.method){
|
||||||
case 'stats':
|
case 'stats':
|
||||||
|
res.header('Content-Type', 'application/json');
|
||||||
res.end(portalStats.statsString);
|
res.end(portalStats.statsString);
|
||||||
return;
|
return;
|
||||||
case 'pool_stats':
|
case 'pool_stats':
|
||||||
|
res.header('Content-Type', 'application/json');
|
||||||
res.end(JSON.stringify(portalStats.statPoolHistory));
|
res.end(JSON.stringify(portalStats.statPoolHistory));
|
||||||
return;
|
return;
|
||||||
case 'payments':
|
case 'payments':
|
||||||
|
@ -25,9 +27,11 @@ module.exports = function(logger, portalConfig, poolConfigs){
|
||||||
for(var pool in portalStats.stats.pools) {
|
for(var pool in portalStats.stats.pools) {
|
||||||
poolBlocks.push({name: pool, pending: portalStats.stats.pools[pool].pending, payments: portalStats.stats.pools[pool].payments});
|
poolBlocks.push({name: pool, pending: portalStats.stats.pools[pool].pending, payments: portalStats.stats.pools[pool].payments});
|
||||||
}
|
}
|
||||||
|
res.header('Content-Type', 'application/json');
|
||||||
res.end(JSON.stringify(poolBlocks));
|
res.end(JSON.stringify(poolBlocks));
|
||||||
return;
|
return;
|
||||||
case 'worker_stats':
|
case 'worker_stats':
|
||||||
|
res.header('Content-Type', 'application/json');
|
||||||
if (req.url.indexOf("?")>0) {
|
if (req.url.indexOf("?")>0) {
|
||||||
var url_parms = req.url.split("?");
|
var url_parms = req.url.split("?");
|
||||||
if (url_parms.length > 0) {
|
if (url_parms.length > 0) {
|
||||||
|
|
Loading…
Reference in New Issue