2026-12-04 12:26:22 -08:00
|
|
|
'use strict';
|
2026-12-04 13:01:19 -08:00
|
|
|
const { fail } = require('../core/ledger');
|
2026-12-04 12:26:22 -08:00
|
|
|
const send = (res, status, data, contentType = 'application/json; charset=utf-8') => {
|
|
|
|
|
res.writeHead(status, { 'Content-Type': contentType });
|
|
|
|
|
res.end(contentType.startsWith('application/json') ? JSON.stringify(data) : data);
|
|
|
|
|
};
|
|
|
|
|
const notFound = () => fail('地址不存在', 404);
|
|
|
|
|
const HTML = 'text/html; charset=utf-8';
|
|
|
|
|
module.exports = { send, notFound, HTML };
|