refactory: status controller
This commit is contained in:
parent
9db25a988e
commit
027935844a
|
@ -15,43 +15,44 @@ exports.show = function(req, res, next) {
|
||||||
res.status(400).send('Bad Request');
|
res.status(400).send('Bad Request');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var s = req.query.q;
|
var option = req.query.q;
|
||||||
var d = Status.new();
|
var statusObject = Status.new();
|
||||||
|
|
||||||
if (s === 'getInfo') {
|
switch(option) {
|
||||||
d.getInfo(function(err) {
|
case 'getInfo':
|
||||||
|
statusObject.getInfo(function(err) {
|
||||||
if (err) next(err);
|
if (err) next(err);
|
||||||
res.jsonp(d);
|
res.jsonp(statusObject);
|
||||||
});
|
});
|
||||||
}
|
break;
|
||||||
else if (s === 'getDifficulty') {
|
case 'getDifficulty':
|
||||||
d.getDifficulty(function(err) {
|
statusObject.getDifficulty(function(err) {
|
||||||
if (err) next(err);
|
if (err) next(err);
|
||||||
res.jsonp(d);
|
res.jsonp(statusObject);
|
||||||
});
|
});
|
||||||
}
|
break;
|
||||||
else if (s === 'getTxOutSetInfo') {
|
case 'getTxOutSetInfo':
|
||||||
d.getTxOutSetInfo(function(err) {
|
statusObject.getTxOutSetInfo(function(err) {
|
||||||
if (err) next(err);
|
if (err) next(err);
|
||||||
res.jsonp(d);
|
res.jsonp(statusObject);
|
||||||
});
|
});
|
||||||
}
|
break;
|
||||||
else if (s === 'getBestBlockHash') {
|
case 'getBestBlockHash':
|
||||||
d.getBestBlockHash(function(err) {
|
statusObject.getBestBlockHash(function(err) {
|
||||||
if (err) next(err);
|
if (err) next(err);
|
||||||
res.jsonp(d);
|
res.jsonp(statusObject);
|
||||||
});
|
});
|
||||||
}
|
break;
|
||||||
else if (s === 'getLastBlockHash') {
|
case 'getLastBlockHash':
|
||||||
d.getLastBlockHash(function(err) {
|
statusObject.getLastBlockHash(function(err) {
|
||||||
if (err) next(err);
|
if (err) next(err);
|
||||||
res.jsonp(d);
|
res.jsonp(statusObject);
|
||||||
});
|
});
|
||||||
}
|
break;
|
||||||
|
default:
|
||||||
else {
|
|
||||||
res.status(400).send('Bad Request');
|
res.status(400).send('Bad Request');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue