ming_node 2.8.0 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,8 @@
1
+ var M=require("../index");
2
+
3
+ app=M.server()
4
+ app.listen(8888)
5
+
6
+ app.get(["/h15","/h16","/h18888"],(req,res)=>{
7
+ res.send("BBBB")
8
+ })
package/index.js CHANGED
@@ -1779,62 +1779,86 @@ M.server = function () {
1779
1779
  app.use(plugin,pluginParams)
1780
1780
  }
1781
1781
 
1782
+ app.registServer=function (url,callback,single){
1783
+ if (Array.isArray(url)) {
1784
+ url.forEach(u=>{
1785
+ single(u,callback);
1786
+ })
1787
+ } else {
1788
+ single(url,callback);
1789
+ }
1790
+ }
1791
+
1782
1792
  /**
1783
1793
  * 注册get请求
1784
1794
  */
1785
1795
  app.get = function (url, callback) {
1786
- url = M.formatUrl(url);
1787
- var realUrl = url;
1788
- if (url.indexOf(":") > 0) {
1789
- url = url.substr(0, url.indexOf(":"));
1790
- G._rest[url] = realUrl;
1796
+ const single=(url,callback)=>{
1797
+ url = M.formatUrl(url);
1798
+ var realUrl = url;
1799
+ if (url.indexOf(":") > 0) {
1800
+ url = url.substr(0, url.indexOf(":"));
1801
+ G._rest[url] = realUrl;
1802
+ }
1803
+ G._get[url] = callback;
1791
1804
  }
1792
-
1793
- G._get[url] = callback;
1805
+ app.registServer(url,callback,single)
1794
1806
  }
1795
1807
  /**
1796
1808
  *注册post请求
1797
1809
  */
1798
1810
  app.post = function (url, callback) {
1799
- url = M.formatUrl(url);
1800
- var realUrl = url;
1801
- if (url.indexOf(":") > 0) {
1802
- url = url.substr(0, url.indexOf(":"));
1803
- G._rest[url] = realUrl;
1811
+ const single=(url,callback)=>{
1812
+ url = M.formatUrl(url);
1813
+ var realUrl = url;
1814
+ if (url.indexOf(":") > 0) {
1815
+ url = url.substr(0, url.indexOf(":"));
1816
+ G._rest[url] = realUrl;
1817
+ }
1818
+ G._post[url] = callback;
1804
1819
  }
1805
- G._post[url] = callback;
1820
+ app.registServer(url,callback,single)
1806
1821
  }
1807
1822
 
1808
1823
  app.put = function (url, callback) {
1809
- url = M.formatUrl(url);
1810
- var realUrl = url;
1811
- if (url.indexOf(":") > 0) {
1812
- url = url.substr(0, url.indexOf(":"));
1813
- G._rest[url] = realUrl;
1824
+ const single=(url,callback)=>{
1825
+ url = M.formatUrl(url);
1826
+ var realUrl = url;
1827
+ if (url.indexOf(":") > 0) {
1828
+ url = url.substr(0, url.indexOf(":"));
1829
+ G._rest[url] = realUrl;
1830
+ }
1831
+ G._put[url] = callback;
1814
1832
  }
1815
- G._put[url] = callback;
1833
+ app.registServer(url,callback,single)
1816
1834
  }
1817
1835
 
1818
1836
  app.delete = function (url, callback) {
1819
- url = M.formatUrl(url);
1820
- var realUrl = url;
1821
- if (url.indexOf(":") > 0) {
1822
- url = url.substr(0, url.indexOf(":"));
1823
- G._rest[url] = realUrl;
1837
+ const single=(url,callback)=>{
1838
+ url = M.formatUrl(url);
1839
+ var realUrl = url;
1840
+ if (url.indexOf(":") > 0) {
1841
+ url = url.substr(0, url.indexOf(":"));
1842
+ G._rest[url] = realUrl;
1843
+ }
1844
+ G._delete[url] = callback;
1824
1845
  }
1825
- G._delete[url] = callback;
1846
+ app.registServer(url,callback,single);
1826
1847
  }
1827
1848
  /**
1828
1849
  *注册任意请求方法的请求
1829
1850
  */
1830
1851
  app.mapping = function (url, callback) {
1831
- url = M.formatUrl(url);
1832
- var realUrl = url;
1833
- if (url.indexOf(":") > 0) {
1834
- url = url.substr(0, url.indexOf(":"));
1835
- G._rest[url] = realUrl;
1852
+ const single=(url,callback)=>{
1853
+ url = M.formatUrl(url);
1854
+ var realUrl = url;
1855
+ if (url.indexOf(":") > 0) {
1856
+ url = url.substr(0, url.indexOf(":"));
1857
+ G._rest[url] = realUrl;
1858
+ }
1859
+ G._mapping[url] = callback;
1836
1860
  }
1837
- G._mapping[url] = callback;
1861
+ app.registServer(url,callback,single);
1838
1862
  }
1839
1863
 
1840
1864
 
package/package.json CHANGED
@@ -46,5 +46,5 @@
46
46
  "scripts": {
47
47
  "test": "echo \"Error: no test specified\" && exit 1"
48
48
  },
49
- "version": "2.8.0"
49
+ "version": "2.9.0"
50
50
  }