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.
- package/beforeTest/test.js +8 -0
- package/index.js +55 -31
- package/package.json +1 -1
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
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
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
|
-
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
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
|
-
|
1820
|
+
app.registServer(url,callback,single)
|
1806
1821
|
}
|
1807
1822
|
|
1808
1823
|
app.put = function (url, callback) {
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
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
|
-
|
1833
|
+
app.registServer(url,callback,single)
|
1816
1834
|
}
|
1817
1835
|
|
1818
1836
|
app.delete = function (url, callback) {
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
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
|
-
|
1846
|
+
app.registServer(url,callback,single);
|
1826
1847
|
}
|
1827
1848
|
/**
|
1828
1849
|
*注册任意请求方法的请求
|
1829
1850
|
*/
|
1830
1851
|
app.mapping = function (url, callback) {
|
1831
|
-
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
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
|
-
|
1861
|
+
app.registServer(url,callback,single);
|
1838
1862
|
}
|
1839
1863
|
|
1840
1864
|
|
package/package.json
CHANGED