dotos 9 rokov pred
rodič
commit
b5f7eadd5a
3 zmenil súbory, kde vykonal 19 pridanie a 7 odobranie
  1. 1 1
      Dockerfile
  2. 10 3
      routes/home.js
  3. 8 3
      routes/v1.js

+ 1 - 1
Dockerfile

@@ -1,4 +1,4 @@
-FROM node:4.4.4
+FROM node:4.5.0
 
 RUN mkdir -p /usr/src/app
 WORKDIR /usr/src/app

+ 10 - 3
routes/home.js

@@ -9,11 +9,18 @@ router.get('/', function(req, res, next) {
     res.header("X-Powered-By",'3.2.1');
     res.header("Vary","Origin");
     res.header("Content-Type", "application/json;charset=utf-8");  
+    var protocol = req.protocol;
+    var host = req.host;
+    var ip = req.ip;
     return res.send({
         code:200,
-        home:'https://ioliu.cn',
-        versions:{
-            v1:'https://api.ioliu.cn/v1/'
+        info:'Welcome, This is a wonderful site',
+        ip:ip,
+        links:{
+            v1: protocol + '://' + host + '/v1/',
+            home:'https://github.com/xCss/JsonBird',
+            HowToUse:'https://github.com/xCss/JsonBird#how-to-use',
+            issue:'https://github.com/xCss/JsonBird/issues'
         }
     });
 });

+ 8 - 3
routes/v1.js

@@ -13,9 +13,14 @@ router.all('/v1/*', function(req, res, next) {
 });
 
 router.get('/', function(req, res, next) {
+    
+    var protocol = req.protocol;
+    var host = req.host;
+    var ip = req.ip;
+
     if (req.originalUrl == /v1/) {
         return res.send({
-            info: 'Please Set URL Like This: https://api.ioliu.cn/v1?url=http[s]://YourWantProxyUrl.com'
+            info: 'Please Set URL Like This: ' + protocol + '://' + host + '/v1?url=http[s]://YourWantProxyUrl.com'
         });
     }
     var url = req.originalUrl.replace('/v1/?url=', '');
@@ -26,9 +31,9 @@ router.get('/', function(req, res, next) {
     console.log(url);
     getJSON(url, function(data) {
         if (req.query.callback) {
-            return res.jsonp(data)
+            return res.jsonp(data);
         } else {
-            return res.json(data)
+            return res.json(data);
         }
     });
 });