Comparing version 0.0.6 to 0.0.7
{ | ||
"name": "io.http", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"author": "Vitaly Anagorsky <vitaly@anagorsky.com>", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -23,2 +23,3 @@ | ||
this.___POST = {} | ||
this.___DELETE = {} | ||
@@ -55,2 +56,10 @@ this.___options = options | ||
delete (api, callback) { | ||
this.___DELETE[api] = callback | ||
return this | ||
} | ||
___listen () { | ||
@@ -62,2 +71,3 @@ | ||
.on('close', () => this.___onClose()) | ||
.on('error', (error) => this.___onError(error)) | ||
.on('listening', () => this.___onListening()) | ||
@@ -75,2 +85,8 @@ .on('request', (req, res) => this.___onRequest(req, res)) | ||
___onError (error) { | ||
process.nextTick(() => this.emit('error', error)) | ||
} | ||
___onListening () { | ||
@@ -107,26 +123,26 @@ | ||
const | ||
headers = req.headers | ||
api = href.pathname | ||
const | ||
ip = ( | ||
headers['x-forwarded-for'] || | ||
req.connection.remoteAddress || | ||
req.socket.remoteAddress || | ||
req.connection.socket.remoteAddress | ||
) | ||
query = querystring.parse(href.query) | ||
const | ||
host = headers['host'] | ||
headers = req.headers | ||
const | ||
protocol = headers['x-forwarded-proto'] || 'http' | ||
host = req.headers['host'] | ||
const | ||
api = href.pathname | ||
protocol = req.headers['x-forwarded-proto'] || 'http' | ||
const | ||
query = querystring.parse(href.query) | ||
method = req.method | ||
const | ||
method = req.method | ||
ip = ( | ||
headers['x-forwarded-for'] || | ||
req.connection.remoteAddress || | ||
req.socket.remoteAddress || | ||
req.connection.socket.remoteAddress | ||
) | ||
@@ -181,2 +197,8 @@ req.___ = { | ||
___resSetStatus (req, res, status) { | ||
res.writeHead(status || 200) | ||
} | ||
___resSend (req, res, data) { | ||
@@ -206,5 +228,4 @@ | ||
res.writeHead(200, { | ||
['content-type']: 'application/json' | ||
}) | ||
this.___resSetHeader(req, res, 'content-type', 'application/json') | ||
this.___resSetStatus(req, res, 200) | ||
@@ -223,5 +244,4 @@ if (this.___options.crypto) { | ||
res.writeHead(200, { | ||
['content-type']: 'text/html' | ||
}) | ||
this.___resSetHeader(req, res, 'content-type', 'text/html') | ||
this.___resSetStatus(req, res, 200) | ||
@@ -254,5 +274,4 @@ res.end(html) | ||
res.writeHead(302, { | ||
['location']: url | ||
}) | ||
this.___resSetHeader(req, res, 'location', 'url') | ||
this.___resSetStatus(req, res, 302) | ||
@@ -259,0 +278,0 @@ res.end() |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5987
193