├── .gitignore
├── .project
├── LICENSE
├── README.md
├── aop
└── TestAop.js
├── api
└── api.js
├── app.js
├── config
├── AppConfig.js
├── RequestResultConfig.js
└── mime.js
├── core
├── Aop.js
├── AppContext.js
├── CacheQueue.js
├── Enhance.js
├── HttpServer.js
├── RequestControllerFilter.js
├── RequestFilterProcessor.js
├── RequestStaticFileFilter.js
├── WelcomeFileFilter.js
├── console.js
├── exception
│ └── Exception.js
├── session
│ ├── SessionContext.js
│ ├── SessionKey.js
│ ├── SessionManager.js
│ └── cookie.js
└── util
│ ├── WebHelper.js
│ ├── dateConverter.js
│ └── debug.js
├── index.html
├── package.json
├── plugs
└── mime
│ ├── mime.js
│ ├── test.js
│ └── types
│ ├── mime.types
│ └── node.types
├── service
├── TestCallback.js
├── TestEnhance.js
└── TestService.js
├── static
├── index.html
├── test.js
└── 新建文本文档.txt
└── ws
├── aio.js
├── index.js
├── ip.js
├── login.js
└── test
└── test1.js
/.gitignore:
--------------------------------------------------------------------------------
1 | lib-cov
2 | *.seed
3 | *.log
4 | *.csv
5 | *.dat
6 | *.out
7 | *.pid
8 | *.gz
9 |
10 | pids
11 | logs
12 | results
13 |
14 | npm-debug.log
15 | node_modules
16 |
--------------------------------------------------------------------------------
/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | springnodejs
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) {year} {fullname}
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | springnodejs
2 | ============
3 | 如果觉得还行,请我喝瓶水
4 | [](http://me.alipay.com/solq)
5 |
6 |
7 |
8 | 作者 : solq
9 |
10 | blog :
11 | * http://www.cnblogs.com/solq/
12 | * http://www.jiaotuhao.com/
13 | * http://www.springnodejs.com/
14 | * http://example.springnodejs.com/
15 | * http://rawcache.springnodejs.com/
16 |
17 | git : https://github.com/solq360/springnodejs
18 |
19 | QQ群:9547527
20 |
21 | * 1.只需要添加 ws Controller 文件就行,启动自动注入 Controller
22 |
23 | * 2.path 路径参数,请求参数自动注入
24 |
25 | * 3.请求参数格式转换,可扩展转换类型
26 |
27 | * 4.容器变量字段自动注入
28 |
29 | * 5.容器初始化执行
30 |
31 | * 6.aop 实现方法拦截
32 |
33 | * 7.url 拦截分发
34 |
35 | * 8.controller 添加回调处理
36 |
37 | 反正是就仿spring 那套
38 |
39 | 给自己打下广告 出售域名
40 |
41 | 各位高富帅,官二代,如果你喜欢这域名就联系一下,价钱保证合理
42 | sell Domain
43 | ```
44 |
45 | beyond1314.cn
46 | 1314beyond.com
47 | xbb520.cn
48 | 0081314.com
49 | bjl123.cn
50 | bbwhere.cn
51 | jiaotuhao.com
52 | 52jmm.com
53 |
54 | ```
55 | 联系QQ:360174425
56 |
57 |
58 | 写起文档,发觉很不容易,大家将就一下吧
59 |
60 | 框架来源:
61 |
62 | 本来想拿 nodejs 做个 ip 查询小应用的,做的时候想着把基础弄好再做应用,没想到做着做着就变成 spring 国内应该没有人做吧
63 |
64 | 至于spring 是什么,大家上网搜下吧
65 |
66 | 我在这里简单介绍一下几个核心概念。由于我本人水平也有限,对于程序的理解也只能在这水平,还没达到深层次,有什么错的请回馈下。
67 |
68 | IOC : 反转控制
69 | --------------------
70 |
71 | 传统写代码方式 如 :
72 | ```
73 | var a={
74 | b : {},
75 | c : {},
76 | d : {}
77 | }
78 |
79 | var d ={
80 | da : 'xxx',
81 | db : 'ccc',
82 | }
83 |
84 | //如果我要用A来工作,是不是先将 A 对象的属于全部初始化才能工作啊??
85 |
86 | a.b = b.da;
87 | a.c = b.db;
88 | ....
89 | a.z = b.z
90 | ```
91 | 大家请思考,如果我要完成一个功能,需要七八个模块,每个模块平均要用到四五个服务/控制类,每个服务/控制 类又要用到 其它的 服务/控制 还有再加上三四个配置资源,到最后每个类都有一大堆的属性要初始化,整个项目共有二三十模块。
92 |
93 | 如果让人去管理的话会疯掉,如果这些都用程序来管理,那是件多么轻松的事啊
94 |
95 | 说真的至于 ioc怎么实义我也不了解概念,我不是学JAVA 的,我只知道他的存在至少帮我处理完以上的事件。
96 |
97 | 那好,现在怎么用程序来做上面海量工作的事情呢? 请看JS 简单实现 ioc
98 | ```
99 | var ar=[];
100 | //容器 1
101 | var o1={
102 | id:'o1',
103 | o2:null
104 | }
105 | //容器 2
106 | var o2={
107 | id:'o2',
108 | o1:null
109 | }
110 | ar.push(o1);
111 | ar.push(o2)
112 |
113 | var ioc={
114 |
115 | }
116 | //注册容器
117 | for(var i in ar){
118 | var obj=ar[i];
119 | ioc[obj.id]=obj;
120 | }
121 |
122 | //容器 属性自动注入
123 | for(var i in ioc){
124 | var obj = ioc[i];
125 |
126 | for(var j in obj){
127 | if(j!='id'){
128 | obj[j]=ioc[j];
129 | }
130 | }
131 | }
132 |
133 | console.log(ioc,o1,o2)
134 | ```
135 | 没错,就是这么简单。每个容器都有自己的ID 标识,只要用来搜索定位,防止复盖。
136 |
137 | 下面是项目的核心处理 AppContext 对象用来管理项目所有的容器,
138 |
139 | 那么主有就几个工作方法 : 生成ID ,查找容器,注册容器,查找一堆相同类型容器 等 具体的规则请看代码实现吧
140 | ```
141 | AppContext={
142 | getKey : function(key){
143 | key = key.trim();
144 | key = key[0].toLowerCase() + key.substring(1,key.length);
145 | return key;
146 | },
147 | findContainer : function(key){
148 | key = this.getKey(key);
149 | return this.data[key];
150 | },
151 | addContainer : function(id,container){
152 | id = this.getKey(id);
153 | container.id= id;
154 | if(this.data[id]!=null ){
155 | _error(" injection key is has : " ,id);
156 | return;
157 | }
158 | this.data[id] = container;
159 | },
160 | findInjectionOfType : function(include,exclude,callBack){
161 | for(var i in this.data){
162 | var container = this.data[i];
163 | if(container.injectionType==null){
164 | continue;
165 | }
166 | var injectionType = container.injectionType;
167 |
168 | if(include!=null && include.indexOf(injectionType)<0){
169 | continue;
170 | }
171 |
172 | if(exclude!=null && exclude.indexOf(injectionType)>-1){
173 | continue;
174 | }
175 |
176 | callBack(container);
177 | }
178 | },
179 | data : {}
180 | }
181 | ```
182 |
183 | 现在来说下注册容器一些流程:
184 |
185 | 1.scan ioc
186 |
187 | 2.auto injection field
188 |
189 | 3.init run
190 |
191 | 1.首先要注明那些是可以注册的,那些是要过滤掉的,那些容器是分别是什么类型。如核心或者服务,控制,或者工作,或者是配置等等
192 |
193 | 最后注入的条件是什么啊等等一大堆问题要处理,程序员就是命苦,生来解决这些的
194 |
195 | 2.注入完成后,接下来就是自动注入属性,我用声明式标识来定义那些是可以注入的,请看示例
196 | ```
197 | {
198 | auto_field1:null,
199 | auto_field3:null,
200 | auto_field4:null,
201 | auto_field5:null,
202 | auto_field6:null,
203 | auto_field20:null,
204 | postConstruct : function(){
205 | debug('init=========================================');
206 | }
207 | };
208 | ```
209 | 通过 auto_(容器ID) 来注入
210 |
211 | 3.注入完了,我们来个初化始来完成自己准备工作
212 |
213 | 大概流程可以抽象出三个方法
214 | ```
215 | _scan();
216 | _auto_injection_field();
217 | _init();
218 | ```
219 |
220 |
221 |
222 |
223 |
224 | 自动扫描,大家用JQUERY 都知道吧,$('CSS选择器') 这样就扫描到一大堆DOM对象 $('id') $('class')
225 |
226 | 我总结了一下
227 |
228 | 用声明式标记那些对象/文件 可以是被扫描到的
229 |
230 | 下面请看项目代码实现
231 |
232 | 扫描配置
233 | ```
234 | var appConfig={
235 | /* * auto scan config* * /
236 | scan :{
237 | './core' : {
238 | injectionType : 'core'
239 | },
240 | './config' : {
241 | injectionType : 'config'
242 | },
243 | './aop' : {
244 | injectionType : 'aop'
245 | },
246 | './service' : {
247 | injectionType : 'service'
248 | },
249 | './ws' : {
250 | filter : '\\ws', //url 服务 过滤器
251 | injectionType : 'controller',
252 | //include : [],
253 | exclude : ['./ws/test/test1.js']
254 | }
255 | }
256 | };
257 | ```
258 |
259 | 有没有注意到 injectionType 这个属于?
260 |
261 | 我目前是按目录来分配容器类型的。这些大家可以在这里扩展自己的容器类型,注入后期 。通过 AppContext.findInjectionOfType 扫描
262 |
263 | 下面是项目实现 ioc 流程
264 |
265 | ```
266 | var _injection = function(filePath,container){
267 | var id = container.id;
268 | if(id == null){
269 | id =_path.basename(filePath).replace('.js','');
270 | }
271 | container.filePath = filePath ;
272 | AppContext.addContainer(id,container);
273 | return container;
274 | }
275 |
276 | var _auto_injection_field = function(){
277 | for(var id in AppContext.data){
278 | if(id == 'appContext'){
279 | continue;
280 | }
281 | var container = AppContext.findContainer(id);
282 |
283 | for(var field in container){
284 | if(field.indexOf('auto_')==0){
285 |
286 | var checkFn = container[field];
287 | if(typeof checkFn == 'function'){
288 | continue;
289 | }
290 | var injectionKey = field.replace('auto_','');
291 |
292 | if(AppContext.findContainer(injectionKey)==null){
293 | _error('injection field not find id : ',field, id );
294 | }else{
295 | container[field] = AppContext.findContainer(injectionKey);
296 | debug("injection field : ",injectionKey,id )
297 | }
298 | }
299 | }
300 | }
301 | }
302 |
303 | var _init = function(){
304 | //为什么分三个初始化阶段呢
305 | //postConstruct 为应用层初始化,如果做服务层扩展的话,就要在应用层初始化之前准备工作,这下明了吧
306 | for(var id in AppContext.data){
307 | var container =AppContext.findContainer(id);
308 | container.awake!=null && container.awake(AppContext);
309 | }
310 |
311 | for(var id in AppContext.data){
312 | var container = AppContext.findContainer(id);
313 | container.start!=null && container.start(AppContext);
314 | }
315 |
316 | for(var id in AppContext.data){
317 | var container = AppContext.findContainer(id);
318 | container.postConstruct!=null && container.postConstruct(AppContext);
319 | }
320 | }
321 |
322 | var _scan = function(){
323 | webHelper.scanProcess(appConfig.scan,'.js',function(filePath,target){
324 | var container=require(filePath);
325 |
326 | //injectionType 查找过滤用的
327 |
328 | if(container.injectionType==null){
329 | var injectionType= target.injectionType;
330 | if(injectionType == null){
331 | injectionType = 'service';
332 | }
333 | container.injectionType = injectionType;
334 | }
335 |
336 | //add filter 过滤器
337 | if(target.filter!=null){
338 | container.filter = target.filter;
339 | }
340 |
341 | var injectionType = container.injectionType ;
342 | var id=_injection(filePath,container).id;
343 | debug( "injection : ",'[',injectionType,']','[',id,']', filePath);
344 | });
345 | }
346 |
347 | _scan();
348 | _auto_injection_field();
349 | _init();
350 | ```
351 | AOP 拦截 面向切面编程
352 | --------------------
353 | 第一次听说估计疯了吧,呵呵也包括我
354 |
355 | 我先来引导一下:
356 | 我们写的代码最终变成
357 | ```
358 | a();
359 | b();
360 | c();
361 | d();
362 | ```
363 | CPU从上往下读取执行,最小单位抽象为方法
364 | 大家请思考一下,程序流是从上往下执行的,如果到了项目后期,要添加某些功能,变成如下这样,那我是不是得修改原来的文件啊,这样会破坏原来的代码,可能会产生未知的BUG,这是程序员最担心受怕的事
365 | ```
366 | a();
367 | e();
368 | b();
369 | c();
370 | d();
371 | ```
372 | 以上代码如果变成
373 | ```
374 | a();
375 | newFn =function(){
376 | e();
377 | b();
378 | }
379 | newFn();
380 | c();
381 | d();
382 |
383 | or
384 |
385 |
386 | newFn =function(){
387 | a();
388 | e();
389 | }
390 | newFn();
391 | b();
392 | c();
393 | d();
394 | ```
395 | 这样是不是不用破坏原来的代码啊?
396 |
397 | 这就是面向切向编程,是的没什么高深的,找到执行的关键点,切入自己处理的逻辑,在切入点之前执行还是之后执行,甚至扩展抛异常执行等等
398 | ------------
399 | 这就是AOP的核心思想,我不明白所有的书籍为什么不会写中文??
400 |
401 | 如果你玩过window程序 钩子,是不是觉得有点似类??
402 | 还有一个应用是改变原来执行方法的输入参数/输出返回 这在数据类型转换应用很扩。举例:
403 | ```
404 | var a = function(int a,Date b){
405 | return int c;
406 | }
407 |
408 | newa=function(int a,string b){
409 | b = Date.str2date(b);
410 | var c=a(a,b);
411 | return c+'';
412 | }
413 |
414 | aop.filter( if(call a?) call newa; );
415 | ```
416 |
417 | 我看过一些书籍,程序补丁就是这样玩的
418 |
419 | 下面是项目aop实现代码 :
420 |
421 | 先看AOP应用 :
422 | ```
423 | module.exports = {
424 | before : {
425 | 'TestService.testAop' : function(originalFuncton,callObj,args){
426 | console.log('aop this is testAop before ==================');
427 | console.log('aop test this value',this.testFiled);
428 | console.log('aop arguments : ',originalFuncton,args);
429 | }
430 | },
431 | after : {
432 | 'TestService.testAop' : function(){ //TestService 是要拦截的容器, testAop 是拦截的方法
433 | console.log('aop this is testAop after ==================');
434 | }
435 | },
436 |
437 | 'testFiled' :'testFiled',
438 | postConstruct : function(){
439 | console.log('aop postConstruct');
440 | },
441 | preDestroy : function(){
442 | console.log('preDestroy');
443 | }
444 | };
445 |
446 | ```
447 |
448 | aop核心JS
449 | ```
450 | /* *
451 | * @author solq
452 | * @deprecated blog: cnblogs.com/solq
453 | * * /
454 | var debug = require('../core/util/debug.js').debug,
455 | _error = require('../core/util/debug.js').error;
456 |
457 | module.exports = {
458 |
459 | awake : function(AppContext){
460 | var $this=this;
461 | AppContext.findInjectionOfType(null,null,function(container){
462 | $this.register(container,AppContext);
463 | });
464 | },
465 | //public
466 | register : function(container,AppContext){
467 | for(var key in container.before){
468 | var filter = container.before[key];
469 | this._aop(key,'before',filter,container, AppContext);
470 | }
471 |
472 | for(var key in container.after){
473 | var filter = container.after[key];
474 | this._aop(key,'after',filter,container,AppContext);
475 | }
476 |
477 | for(var key in container.error){
478 | var filter = container.error[key];
479 | this._aop(key,'error',filter,container,AppContext);
480 | }
481 | },
482 |
483 | //private
484 | _aop : function(key,aopType,filter,thisObj,AppContext){
485 | var sp = key.split('.'),
486 | id = sp[0],
487 | fnName = key.substring(key.indexOf('.')+1, key.length );
488 | var container=AppContext.findContainer(id);
489 | if(container==null){
490 | _error("aop not find container : ",key, " id :",id);
491 | return;
492 | }
493 |
494 | var originalFuncton =null;
495 | try{
496 | originalFuncton = eval('container.'+ fnName);
497 | }catch(e){
498 | _error(e);
499 | _error("aop not find originalFuncton: ",key, " id :",id );
500 | return;
501 | }
502 |
503 | if(originalFuncton==null){
504 | _error("aop not find originalFuncton: ",key, " id :",id );
505 | return;
506 | }
507 |
508 | if(typeof originalFuncton!= "function"){
509 | _error("aop originalFuncton is not function ",key, " id :",id );
510 | return;
511 | }
512 |
513 | var newFuntion=null;
514 | switch(aopType){
515 | case 'error':
516 | newFuntion=function(){
517 | try{
518 | originalFuncton.apply(container,arguments);
519 | }catch(e){
520 | filter.apply(thisObj,arguments);
521 | }
522 | }
523 | break;
524 | case 'after':
525 | newFuntion=function(){
526 | var result=originalFuncton.apply(container,arguments);
527 | filter.apply(thisObj,arguments);
528 | return result;
529 | }
530 | break;
531 | case 'before':
532 | newFuntion=function(){
533 | //debug("originalFuncton : " , originalFuncton.toString());
534 | var isCallFlag=filter.call(thisObj,originalFuncton,container,arguments);
535 |
536 | if(!isCallFlag){
537 | return originalFuncton.apply(container,arguments);
538 | }
539 | }
540 | break;
541 | }
542 |
543 | container[fnName]=newFuntion;
544 | }
545 | };
546 | ```
547 | 声明式开发
548 | ------------
549 | 我第一次见别人写java注解就完成开发了,感觉太写意哈哈.
550 | 举例之前 auto_ 标识
551 | ```
552 | {
553 | auto_field1:null,
554 | auto_field2:null,
555 | auto_field3:null,
556 | auto_field4:null,
557 | }
558 | ```
559 | 也可以多种声明
560 | ```
561 | module.exports = {
562 | auto_cacheDate : null,
563 | 'delete:/user/{id}/{name}':{
564 | controller : function(path_name,path_id,req, res){
565 | this.auto_cacheDate="add data";
566 | console.log("testpath",arguments);
567 | }
568 | },
569 | 'get|post:/user':{
570 | controller : function(param_p1,param_def_array_p1,body_xxx){
571 | console.log("testpath",arguments,this.auto_cacheDate);
572 | }
573 | }
574 | };
575 | ```
576 | param_def_array_ 三种声明绑定一个属性 由于JS语言没有 java @注解 我只有能想到用 标识+_ 来做程序处理,看起来有点怪怪的哈哈
577 | 上面这个是 REST 设计风格,下面会介绍的
578 |
579 | 只要声明程序预处理的时候帮你自动注了,你也可以自定义标识对应相应处理
580 |
581 | ```
582 | {
583 | "声明1":"处理器1",
584 | "声明2":"处理器2",
585 | "声明3":"处理器3",
586 | "声明4":"处理器4",
587 | }
588 | ```
589 |
590 |
591 | 我总结了一下,用声明式开发只在是在程序预处理的时候,为了减少程序逻辑的复杂性,加标识扫描处理,类型声明转换,添加处理器等。
592 | 这种好处也只能在预处理阶段应用很好,如果在应用层做的话就失去优势。
593 | 大家思考一下 : 本来是为了减少程序复杂性用人工去硬写入绑定,如果在应用层大量用声明的话,绝对是苦力活。
594 | 我看到有的UI框架把HTML做成声明式,那绝对是苦力活,本来用js 动态生成HTML 干掉HTML化,他反而要把功能声明依赖HTML 想到一个页面有多少个HTML标签就想死了
595 |
596 | REST 设计风格 面向资源设计
597 | ------------
598 |
599 | * 设计的作者将世界每样东西都看成是一种资源
600 | * 对每种资源基本操作有: 产生(create) ,变更(change) ,删除(delete),传播 (spread)
601 |
602 | 是不是有点像数据库 增删改查 操作啊
603 | 那好,有这种概念,跟http有什么关系呢?
604 |
605 | 一个 http url 地址就是一种资源,对每个 url 有四种基本操作
606 |
607 | ```
608 | url method
609 | http://www.jiaotuhao.com/test GET (get data)
610 | http://www.jiaotuhao.com/test POST (create data)
611 | http://www.jiaotuhao.com/test PUT (change data)
612 | http://www.jiaotuhao.com/test DELETE (delete data)
613 | ```
614 |
615 | * 大家可能比较了解的是 post get 请求对吧,其实还有很多请求的,我不说你知道吗?
616 | * 将这四种操作跟业务联系在一起,就变成以上这样了。
617 | * 当然,你设计的URL 不一定按照上面规范,规则是死的人是活的
618 |
619 | 下面再举个例子,带参数的
620 | ```
621 | url method
622 | http://www.jiaotuhao.com/user/{id} GET (get data.id=={id})
623 | http://www.jiaotuhao.com/user/{id} POST (create data.id={id})
624 | http://www.jiaotuhao.com/user/{id} PUT (change data.id={id})
625 | http://www.jiaotuhao.com/user/{id} DELETE (delete data.id={id})
626 | ```
627 | * ID是数据唯一记录KEY,每种记录也可以看成是一种资源。
628 | * 而 /user/ 可以看成是业务一种处理,或者是/user/ 子资源
629 | * 这就是面向资源设计啊,如果还是觉得抽象,看看WINDOW 资源管理器
630 |
631 | 如下是项目使用的例子 :请跟 express 对比一下
632 |
633 | ```
634 | module.exports = {
635 | 'delete:/user':{
636 | auth : [],//权限
637 | controller : function(request, response){
638 | console.log("testpath",arguments);
639 | }
640 | },
641 | 'get|post:/user':{
642 | auth : [],//权限
643 | controller : function(request, response){
644 | console.log("testpath",arguments);
645 | }
646 | }
647 | };
648 | ```
649 |
650 | ```
651 | module.exports = {
652 | cacheData : null,
653 | 'get:/user/{id}/{name}':{
654 | controller : function(path_name,path_id,req, res){
655 | this.cacheData="add data";
656 | console.log("testpath",arguments);
657 | }
658 | },
659 | 'get|post:/user':{
660 | controller : function(param_int_p1,param_array_p2,body_xxx){
661 | console.log("testpath",arguments,this.cacheData);
662 | }
663 | }
664 | };
665 | ```
666 | 'get:/user/{id}/{name}' 真实请求路径 http://www.jiaotuhao.com/ws/user/bbb/ccc
667 | ws 是拦截服务的标识,在那里配置呢?
668 |
669 | appconfig.js filter 属性
670 | ```
671 | scan :{
672 | './ws' : {
673 | filter : '\\ws', //url 服务 过滤器
674 | injectionType : 'controller',
675 | //include : [],
676 | exclude : ['./ws/test/test1.js']
677 | },
678 | './api' : {
679 | filter : '\\api', //url 服务 过滤器
680 | injectionType : 'controller'
681 | }
682 | }
683 | ```
684 | 为什么要加个/ws/前缀标识呢? 不同的服务可能处理不同,这时候只要添加相应的拦截器就满足不同的处理
685 | 比如 api 服务,他可能不需要权限验证就可以访问
686 |
687 | * path_(pathKey) 就会自动将你想要的值注入了
688 | * param_ 将 http://www.jiaotuhao.com/ws/user/bbb/ccc?p1=2332&p2=kkk p1参数注入
689 | * body_ 将?p1=2332&p2=kkk 变成 json={p1:2332,p2:'kkk'}注入
690 | * int_ array_ date_ 数据类型转换
691 |
692 | 上面这些工作,程序都帮你弄好了。做出来的程序是为别人服务的,为什么不能先为自己服务呢?
693 |
694 | 实际结合声明式开发+自动注入
695 |
696 | REST CALLBACK 添加回调处理
697 | ------------
698 |
699 | 下面项目举例
700 |
701 | ```
702 | module.exports = {
703 | value :'xxxxx',
704 | '/aio':{ //注入 callback 回调方法,一定要调用才结束
705 | controller : function(req, res,callback){
706 | var $this = this;
707 | console.log("sync" , this.value);
708 | setTimeout(function(){
709 | console.log("sync end ================",$this.value);
710 | callback(5555555); //执行回调
711 | console.log("sync end ================",$this.value);
712 | },2000);
713 | }
714 | }
715 | };
716 | ```
717 |
718 | 上面只要在 controller 参数声明 callback 在结束时调用一下就完成工作
719 | 我大概说下流程
720 | * 1.在程序预处理时,扫描 controller 参数,发现 callback 声明标识 标记该 controller.sync = false
721 | * 2.url拦截完成时,进行参数注入,通过 controller.sync 进行处理
722 | * 3.通过拦载成功,执行 拦载器 filterSuccessCallback 方法
723 |
724 | 下面是核心代码
725 |
726 | ```
727 | //注入处理
728 |
729 | var otherKey ={'req':request,'res':response,'request':request, 'response':response ,'callback' : function(result){ $this.filterSuccessCallback(request,response,result) ;} };
730 | otherKey[param];
731 |
732 | var sync = paramsMetadata.sync;
733 | var result = controller.apply(callObj,callParams);
734 | if(sync){
735 | return this.auto_requestResultConfig.successValueOf(result);
736 | }else{
737 | return this.auto_requestResultConfig.callbackValueOf();
738 | }
739 |
740 | ```
741 |
742 | 大家可能会觉得很模糊,只需要知道怎么调用就行了
743 | 以后会介绍一下 url 拦载器,怎么处理url拦截分发的
744 |
745 | AOP 增强实战
746 | ------------
747 | 很多人觉得AOP很少用到,其实原理的东西看似简单/复杂,但深入理解后,应用非常之扩
748 | 通过本例将见证改变 程序员(js)的书写方式,给人印象非常深刻
749 | 哈哈,首先还是通过引导。见下面js例子
750 | ```
751 | fn1(function(){
752 | fn2(function(){
753 | fn3(function(){
754 | fn4();
755 | .....
756 | });
757 | });
758 | });
759 | ```
760 | 写过JS的人都知道上面的代码是多头痛,第二次看肯定有想死的感觉
761 | 假如代码变成这样
762 | ```
763 | var v1= callback_fn1();
764 | var v2= callback_fn2(v1);
765 | var v3= callback_fn3(v2);
766 |
767 | //以上是程序未运行时的代码
768 | //通过拦截进行改写
769 |
770 | //第一次改写
771 | var v1= callback_fn1(function(v1){
772 | var v2= callback_fn2(v1);
773 | var v3= callback_fn3(v2);
774 | });
775 | //第二次改写
776 | var v1= callback_fn1(function(v1){
777 | var v2= callback_fn2(function(v2){
778 | var v3= callback_fn3(v2);
779 | });
780 | });
781 | //第三次改写 最终代码变成这样
782 | var v1= callback_fn1(function(v1){
783 | var v2= callback_fn2(function(v2){
784 | var v3= callback_fn3(function(v3){
785 |
786 | });
787 | });
788 | });
789 |
790 | ```
791 | 我们书写的代码是同步的,相通上面介绍声明式开发,在异步的方法添加标识,程序预处理时自动改写代码,是不是很酷啊。
792 | 下面是项目简单实现,因为改写规则太多,要完善的话要花很多精力。
793 |
794 | 首先添加个 异步的方法
795 | testEnhance.js
796 | ```
797 | module.exports = {
798 | callback_test1 : function(callback){
799 | var result = ' callback_test1 result value';
800 | setTimeout(function(){
801 | callback!=null && callback(result);
802 | },10000);
803 | }
804 | };
805 | ```
806 | 示例代码
807 | ```
808 | module.exports = {
809 | auto_testEnhance : null,
810 | start : function(){
811 | await:
812 | var value = this.auto_testEnhance.callback_test1();
813 | await:
814 | var value2 = this.auto_testEnhance.callback_test1();
815 |
816 | console.log(" test callback1 ===================", value);
817 | console.log(" test callback2 ===================", value2);
818 | endawait;
819 | endawait;
820 | }
821 | };
822 | ```
823 |
824 | aop 增强核心
825 | 我先说下处理流程
826 |
827 | * 1 先扫描 function 代码
828 | * 2 注入增强代码
829 | * 3 重写原来方法
830 |
831 | 流程有了,那么可以抽象出三个方法
832 | _scanCode();
833 | _injectionCode();
834 | _overrideFunction();
835 |
836 | ```
837 | /**
838 | * @author solq
839 | * @deprecated blog: cnblogs.com/solq
840 | * */
841 | var debug = require('../core/util/debug.js').debug,
842 | _error = require('../core/util/debug.js').error;
843 | var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
844 | module.exports = {
845 | injectionType : 'aop',
846 | awake : function(AppContext){
847 | var $this=this;
848 | var container=AppContext.findContainer('TestCallback');
849 | //AppContext.findInjectionOfType(null,['aop'],function(container){
850 | $this.register(container);
851 | //});
852 | },
853 | //public
854 | register : function(container){
855 | for(var key in container){
856 | var fn = container[key];
857 | if(typeof fn != 'function'){
858 | continue;
859 | }
860 | this._aop(key,fn,container);
861 | }
862 | },
863 | scanMarker : 'callback_',
864 | //private
865 | _aop : function(fnName,fn,container){
866 | //scan code
867 | //injection code
868 | //overrideFunction
869 | var codestring = this._scanCode(fn);
870 | if(codestring.indexOf( this.scanMarker) <0 ){
871 | return;
872 | }
873 | var new_codestring = this._injectionCode(codestring);
874 | var newFuntion = this._overrideFunction(new_codestring);
875 | container[fnName]=newFuntion;
876 | },
877 |
878 | _scanCode : function(fn){
879 | var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
880 | var code=fn.toString().replace(STRIP_COMMENTS, '');
881 | return code.substring(code.indexOf('{')+1, code.lastIndexOf('}'));
882 | //return code.slice(code.indexOf('{')+1, code.lastIndexOf('}')).match(/([^\n,]+)/g).filter(function(e){return e});
883 | },
884 | _injectionCode : function(codestring){
885 | var _injection_start ="var __$this = this;";
886 | var _injection_end ="})";
887 |
888 | codestring = codestring.replace(/(var\s+(.*)\=.*callback_[^)]+)(.*)/mg,function(a,b,c,d){
889 | //debug("codestring replace ==============",a," b====== ",b," c=============== ",c, " d============== ",d);
890 | var _injection_code ="(function("+c+"){";
891 | var result =a.replace("\(\)",_injection_code);
892 | //debug("result ====================",result);
893 | return result;
894 | });
895 |
896 | //第一版本替换
897 | /*
898 | while(i>0){
899 | i--;
900 | codestring += _injection_end;
901 | }*/
902 | //第二版本替换
903 | codestring = codestring.replace(/await\s*\:/mg,'');
904 | codestring = codestring.replace(/endawait\s*;/mg,_injection_end);
905 | //replace this
906 | codestring = codestring.replace(/this\s*\./mg,'__$this.');
907 | codestring = _injection_start + codestring;
908 |
909 | debug("new code ==============",codestring);
910 | return codestring;
911 | },
912 | _overrideFunction : function(new_codestring){
913 | return new Function(new_codestring);
914 | },
915 | };
916 | ```
917 | 好了,目前就写在这里
918 |
919 | 如果觉得还行,请我喝瓶水
920 | [](http://me.alipay.com/solq)
--------------------------------------------------------------------------------
/aop/TestAop.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 | module.exports = {
6 | before : {
7 | 'TestService.testAop' : function(originalFuncton,callObj,args){
8 | console.log('aop this is testAop before ==================');
9 | console.log('aop test this value',this.testFiled);
10 | console.log('aop arguments : ',originalFuncton,args);
11 | }
12 | },
13 | after : {
14 | 'TestService.testAop' : function(){
15 | console.log('aop this is testAop after ==================');
16 | }
17 | },
18 |
19 | 'testFiled' :'testFiled',
20 | postConstruct : function(){
21 | console.log('aop postConstruct');
22 | },
23 | preDestroy : function(){
24 | console.log('preDestroy');
25 | }
26 | };
27 |
--------------------------------------------------------------------------------
/api/api.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 | var fs = require('fs'),
6 | queryUrl = require('url'),
7 | _error = require('../core/util/debug.js').error;
8 | debug = require('../core/util/debug.js').debug,
9 | webHelper = require('../core/util/WebHelper.js'),
10 | CacheQueue = require('../core/CacheQueue.js');
11 |
12 | module.exports = {
13 |
14 | '/':{
15 | controller : function(req){
16 | return 'xxx';
17 | }
18 | },
19 | '/index':{
20 | controller : function(){
21 | return {'code':200,data:{'xx':'测试中文'}};
22 | }
23 | }
24 | };
25 |
--------------------------------------------------------------------------------
/app.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 | var appContext = require("./core/AppContext.js");
6 |
7 | appContext.runServer();
8 |
9 | var httpServer = appContext.findContainer("httpServer");
10 | httpServer.runServer();
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/config/AppConfig.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 | var appConfig={
6 | author: 'solq',
7 | /**db config**/
8 | dbHost : '127.0.0.1',
9 | dbPort : 9977 ,
10 | dbUser : '',
11 | dbPasssWord : '',
12 |
13 | /**debug config**/
14 | LOGDEBUG : 1,
15 | LOGINFO : 2,
16 | LOGERROR : 4,
17 | LOGLEVEL : (1 | 4),
18 |
19 | /**web config**/
20 | projectName : 'REST',
21 | version : '0.01',
22 | webPort : 5555,
23 |
24 | /**web config**/
25 | startCacheStatic : true,
26 | /**controller filter config**/
27 | welcomeFilters : ['\\','\\index.html','\\login.html'],
28 | webServiceFilters : ['\\ws','\\api'],
29 | staticFileFilters : ['\\static','\\abc'],
30 | /**auto scan config**/
31 | scan :{
32 | './core' : {
33 | injectionType : 'core'
34 | },
35 | './config' : {
36 | injectionType : 'config'
37 | },
38 | './aop' : {
39 | injectionType : 'aop'
40 | },
41 | './service' : {
42 | injectionType : 'service'
43 | },
44 | './ws' : {
45 | filter : '\\ws', //url 服务 过滤器
46 | injectionType : 'controller',
47 | //include : [],
48 | exclude : ['./ws/test/test1.js']
49 | },
50 | /*'./api' : {
51 | filter : '\\api', //url 服务 过滤器
52 | injectionType : 'controller'
53 | }*/
54 | }
55 | };
56 |
57 | module.exports = appConfig;
--------------------------------------------------------------------------------
/config/RequestResultConfig.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 |
6 | module.exports = {
7 | 'failuer' : 'failuer', //过滤失败
8 | 'success' : 'success', //过滤成功
9 | 'callback' : 'callback',//过滤成功 并且属于 callback
10 | 'filterProcess' : 'filterProcess', //只是拦截处理,似类于中间件
11 | //返回封装
12 |
13 | 'failuerValueOf' :function(body){
14 | return { statu : 'failuer' , body : body }
15 | },
16 | 'successValueOf' :function(body){
17 | return { statu : 'success' , body : body }
18 | },
19 | 'callbackValueOf' :function(callback){
20 | return { statu : 'callback' , body : callback }
21 | },
22 | 'filterProcessValueOf' :function(callback){
23 | return { statu : 'filterProcess' , body : callback }
24 | }
25 | };
--------------------------------------------------------------------------------
/config/mime.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * plugs mime : https://github.com/broofa/node-mime
5 | * */
6 | var mime = require('../plugs/mime/mime.js'),
7 | debug = require('../core/util/debug.js').debug,
8 | _path = require('path'),
9 | url = require('url');
10 | module.exports = {
11 | /*
12 | awakexx : function(){
13 | var pathname='../../test.php.text.html';
14 |
15 | debug('init mime lookup:' ,mime.lookup(pathname));
16 | debug('init mime lookup:' ,mime.lookup('../ws/test?xxx=bbb'));
17 | debug('path join:' ,_path.join("static", pathname) );
18 |
19 | var realPath = _path.join("assets", _path.normalize(pathname.replace(/\.\./g, "")));
20 | debug('mime realPath:' ,realPath);
21 | },*/
22 | lookup : function(path){
23 | return mime.lookup(path);
24 | },
25 | extension : function(type){
26 | return mime.extension(type);
27 | }
28 | };
--------------------------------------------------------------------------------
/core/Aop.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 | var debug = require('../core/util/debug.js').debug,
6 | _error = require('../core/util/debug.js').error;
7 |
8 | module.exports = {
9 |
10 | awake : function(AppContext){
11 | var $this=this;
12 | AppContext.findInjectionOfType(['aop'],null,function(container){
13 | $this.register(container,AppContext);
14 | });
15 | },
16 | //public
17 | register : function(container,AppContext){
18 | for(var key in container.before){
19 | var filter = container.before[key];
20 | this._aop(key,'before',filter,container, AppContext);
21 | }
22 |
23 | for(var key in container.after){
24 | var filter = container.after[key];
25 | this._aop(key,'after',filter,container,AppContext);
26 | }
27 |
28 | for(var key in container.error){
29 | var filter = container.error[key];
30 | this._aop(key,'error',filter,container,AppContext);
31 | }
32 | },
33 |
34 | //private
35 | _aop : function(key,aopType,filter,thisObj,AppContext){
36 | var sp = key.split('.'),
37 | id = sp[0],
38 | fnName = key.substring(key.indexOf('.')+1, key.length );
39 | var container=AppContext.findContainer(id);
40 | if(container==null){
41 | _error("aop not find container : ",key, " id :",id);
42 | return;
43 | }
44 |
45 | var originalFuncton =null;
46 | try{
47 | originalFuncton = eval('container.'+ fnName);
48 | }catch(e){
49 | _error(e);
50 | _error("aop not find originalFuncton: ",key, " id :",id );
51 | return;
52 | }
53 |
54 | if(originalFuncton==null){
55 | _error("aop not find originalFuncton: ",key, " id :",id );
56 | return;
57 | }
58 |
59 | if(typeof originalFuncton!= "function"){
60 | _error("aop originalFuncton is not function ",key, " id :",id );
61 | return;
62 | }
63 |
64 | var newFuntion=null;
65 | switch(aopType){
66 | case 'error':
67 | newFuntion=function(){
68 | try{
69 | originalFuncton.apply(container,arguments);
70 | }catch(e){
71 | filter.apply(thisObj,arguments);
72 | }
73 | }
74 | break;
75 | case 'after':
76 | newFuntion=function(){
77 | var result=originalFuncton.apply(container,arguments);
78 | filter.apply(thisObj,arguments);
79 | return result;
80 | }
81 | break;
82 | case 'before':
83 | newFuntion=function(){
84 | //debug("originalFuncton : " , originalFuncton.toString());
85 | var isCallFlag=filter.call(thisObj,originalFuncton,container,arguments);
86 |
87 | if(!isCallFlag){
88 | return originalFuncton.apply(container,arguments);
89 | }
90 | }
91 | break;
92 | }
93 |
94 | container[fnName]=newFuntion;
95 | }
96 | };
--------------------------------------------------------------------------------
/core/AppContext.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 | var http = require("http"),
6 | fs = require("fs"),
7 | _path = require("path"),
8 | appConfig = require('../config/AppConfig.js'),
9 | webHelper = require('../core/util/WebHelper.js'),
10 | debug = require('../core/util/debug.js').debug,
11 | _error = require('../core/util/debug.js').error;
12 |
13 | var AppContext={
14 | auto_console : null,
15 | _isStart : false,
16 | runServer : function(){
17 |
18 | if(this._isStart) return;
19 | this._isStart = true;
20 | //IOC 控制流程
21 | //1.scan
22 | //2.auto injection field
23 | //3.init run
24 |
25 | debug( "start injection : =============================================");
26 | _scan();
27 | debug( "end injection : =========================================");
28 | debug( "=========================================");
29 | debug( "=========================================");
30 |
31 | debug( "start injection field : =============================================");
32 | _auto_injection_field();
33 | debug( "end injection field : =============================================");
34 |
35 | debug( "=========================================");
36 | debug( "=========================================");
37 |
38 | //init run
39 | debug( "start init : =============================================");
40 | _init();
41 | debug( "end init : =============================================");
42 |
43 | //register console commond
44 |
45 | this.auto_console.register("close_server",function(){
46 | //trigger close server event
47 | _end();
48 | process.exit(0);
49 | debug( "close_server : =============================================");
50 | });
51 | this.auto_console.run();
52 | },
53 | findContainer : function(key){
54 | key = this.getKey(key);
55 | return this.data[key];
56 | },
57 | addContainer : function(id,container){
58 | id = this.getKey(id);
59 | container.id= id;
60 | if(this.data[id]!=null ){
61 | _error(" injection key is has : " ,id);
62 | return;
63 | }
64 | this.data[id] = container;
65 | },
66 | findInjectionOfType : function(include,exclude,callBack){
67 | for(var i in this.data){
68 | var container = this.data[i];
69 | if(container.injectionType==null){
70 | continue;
71 | }
72 | var injectionType = container.injectionType;
73 |
74 | if(include!=null && include.indexOf(injectionType)<0){
75 | continue;
76 | }
77 |
78 | if(exclude!=null && exclude.indexOf(injectionType)>-1){
79 | continue;
80 | }
81 |
82 | callBack(container);
83 | }
84 | },
85 | getKey : function(key){
86 | key = key.trim();
87 | key = key[0].toLowerCase() + key.substring(1,key.length);
88 | return key;
89 | },
90 | data : {}
91 | };
92 |
93 | //处理功能方法
94 | var _injection = function(filePath,container){
95 | var id = container.id;
96 | if(id == null){
97 | id =_path.basename(filePath).replace('.js','');
98 | }
99 | container.filePath = filePath ;
100 | AppContext.addContainer(id,container);
101 | return container;
102 | }
103 |
104 | var _scan = function(){
105 | webHelper.scanProcess(appConfig.scan,'.js',function(filePath,target){
106 | var container=require('../'+filePath);
107 |
108 | //injectionType 查找过滤用的
109 |
110 | if(container.injectionType==null){
111 | var injectionType= target.injectionType;
112 | if(injectionType == null){
113 | injectionType = 'service';
114 | }
115 | container.injectionType = injectionType;
116 | }
117 |
118 | //add filter 过滤器
119 | if(target.filter!=null){
120 | container.filter = target.filter;
121 | }
122 |
123 | var injectionType = container.injectionType ;
124 | var id=_injection(filePath,container).id;
125 | debug( "injection : ",'[',injectionType,']','[',id,']', filePath);
126 | });
127 | }
128 |
129 | var _auto_injection_field = function(){
130 | for(var id in AppContext.data){
131 |
132 | var container = AppContext.findContainer(id);
133 |
134 | for(var field in container){
135 | if(field.indexOf('auto_')==0){
136 |
137 | var checkFn = container[field];
138 | if(typeof checkFn == 'function'){
139 | continue;
140 | }
141 | var injectionKey = field.replace('auto_','');
142 |
143 | if(AppContext.findContainer(injectionKey)==null){
144 | _error('injection field not find id : ',field, id );
145 | }else{
146 | container[field] = AppContext.findContainer(injectionKey);
147 | debug("injection field : ",injectionKey,id )
148 | }
149 | }
150 | }
151 | }
152 | }
153 |
154 | var _init = function(){
155 | //为什么分三个初始化阶段呢
156 | //postConstruct 为应用层初始化,如果做服务层扩展的话,就要在应用层初始化之前准备工作,这下明了吧
157 | for(var id in AppContext.data){
158 | var container =AppContext.findContainer(id);
159 | container.awake!=null && container.awake(AppContext);
160 | }
161 |
162 | for(var id in AppContext.data){
163 | var container = AppContext.findContainer(id);
164 | container.start!=null && container.start(AppContext);
165 | }
166 |
167 | for(var id in AppContext.data){
168 | var container = AppContext.findContainer(id);
169 | container.postConstruct!=null && container.postConstruct(AppContext);
170 | }
171 | }
172 |
173 | var _end = function(){
174 | for(var id in AppContext.data){
175 | var container = AppContext.findContainer(id);
176 | container.preDestroy!=null && container.preDestroy(AppContext);
177 | }
178 | }
179 |
180 | module.exports = AppContext;
--------------------------------------------------------------------------------
/core/CacheQueue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 | var _error = require('../core/util/debug.js').error;
6 | debug = require('../core/util/debug.js').debug;
7 | (function(){
8 | var CacheQueue=function(name, isPermanent , weightValue,maxLength,clearTimerTime){
9 | //public
10 | this.name = name; //缓存器名称
11 | this.maxLength = maxLength || 10000; //队列最大长度
12 | this.clearTimerTime = clearTimerTime || 1000 * 60 * 10 ; //十分钟清一次队列
13 | this.weightValue = weightValue || 0.6; //权重值,算出来低于这值的记录都清除
14 | //private
15 | this.isPermanent = isPermanent || false; //是否永久保存;
16 | this.pointer = 0; //当前队列指针
17 | this.lastClearTime = 0; //最后一次清空缓存队列时间
18 | this.queue = {}; //数据
19 | }
20 |
21 | /**添加数据*/
22 | CacheQueue.prototype.add=function(data){
23 |
24 | if(!this.isPermanent && this.pointe>=this.maxLength){
25 | //clear
26 | this.clearTimer();
27 | }
28 | if(typeof data != 'object'){
29 | var data = {
30 | id : data,
31 | data : data
32 | };
33 | }
34 | var id= this.getId(data);
35 | if( this.queue[id] ==null){
36 | this.pointer++;
37 | }
38 | data.lastTime=new Date().getTime();
39 | data.readNum=0;
40 | this.queue[id]=data;
41 | }
42 |
43 | /**清理数据处理器*/
44 | CacheQueue.prototype.clearTimer=function(){
45 | var now=new Date().getTime();
46 | for(var key in this.queue){
47 | var obj= this.queue[key];
48 | if(this.getWeight(obj,now)0){
76 | i--;
77 | codestring += _injection_end;
78 | }*/
79 | //第二版本替换
80 | codestring = codestring.replace(/await\s*\:/mg,'');
81 | codestring = codestring.replace(/endawait\s*;/mg,_injection_end);
82 |
83 | //replace this
84 | codestring = codestring.replace(/this\s*\./mg,'__$this.');
85 | codestring = _injection_start + codestring;
86 |
87 | debug("new code ==============",codestring);
88 | return codestring;
89 | },
90 | _overrideFunction : function(new_codestring,params){
91 | if(params.length==0){
92 | return new Function(new_codestring);
93 | }
94 | return new Function(params,new_codestring);
95 | }
96 | };
--------------------------------------------------------------------------------
/core/HttpServer.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 | var http = require("http"),
6 | debug = require('../core/util/debug.js').debug,
7 | _error = require('../core/util/debug.js').error;
8 |
9 | module.exports = {
10 | auto_requestFilterProcessor : null,
11 | auto_appConfig : null,
12 | auto_appContext : null,
13 | injectionType : 'core',
14 |
15 | runServer : function(){
16 |
17 | $this = this;
18 | http.createServer(function(request, response) {
19 | //响应流由拦截器内部关闭
20 | try{
21 | $this.auto_requestFilterProcessor.filter(request, response,$this.auto_appContext);
22 | }catch(e){
23 | $this.errorRequest(response,e);
24 | }
25 | }).listen($this.auto_appConfig.webPort);
26 | debug("run http server ",$this.auto_appConfig.webPort);
27 | },
28 | errorRequest : function(response,e){
29 | response.writeHead(500, {"Content-Type": "text/plain;charset=utf-8"});
30 | _error(e.stack,e);
31 | response.write(e.stack);
32 | response.end();
33 | }
34 | };
35 |
--------------------------------------------------------------------------------
/core/RequestControllerFilter.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 | var queryUrl = require("url"),
6 | _path = require("path"),
7 | queryString = require( "querystring" ),
8 | debug = require('../core/util/debug.js').debug,
9 | _error = require('../core/util/debug.js').error,
10 | dateConverter = require('../core/util/dateConverter.js');
11 |
12 | var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
13 |
14 | var requestController={
15 |
16 | auto_requestResultConfig : null,
17 | auto_appConfig : null,
18 | auto_cookie : null,
19 | auto_sessionManager : null,
20 |
21 | _urlData : {},
22 | _pathData : {},
23 | //_paramData : {},
24 | //_pathParamData : {},
25 | injectionType : 'filter', //属于拦截服务
26 | filterValue : null, //拦截的url 起始标识
27 | order : 2,
28 | awake : function(AppContext){
29 |
30 | this.filterValue = this.auto_appConfig.webServiceFilters;
31 |
32 | var $this=this;
33 | AppContext.findInjectionOfType(['controller'],null,function(container){
34 | $this.register(container);
35 | });
36 | },
37 | /**
38 | 保存方法参数元数据结构
39 | {
40 | sawName : 原始的参数名
41 | name : 参数名
42 | index : 参数下标
43 | type : 参数类型 如 string array int date object
44 | pathIndex : 对应路径参数下标
45 | mapType : 映身处理的类型 如 path param body other
46 | required : 是否注入 默认都为 true
47 | }
48 | */
49 | getParamMetadata : function(params,url){
50 | //path 处理
51 | if(url.lastIndexOf('/') == url.length && url.length !=1){
52 | url = url.substring(0, url.length - 1).trim();
53 | }
54 | var checkPath = url.replace(/{([^}]+)}/gm,function(a,b,c){
55 | return '{}';
56 | });
57 | var checkGroup = checkPath.split("/").filter(function(e){return e}),
58 | sawGroup = url.split("/").filter(function(e){return e});
59 |
60 | var result = {
61 | queryParams : {},
62 | pathParamData : {},
63 | paramData : {},
64 | otherData : {},
65 | bodyData : null,
66 | pathParamLength : 0,
67 | paramLength : 0,
68 | checkParamLength : 0,
69 | otherLength : 0 ,
70 | sync : true,
71 | sawPath : url ,
72 | checkPath : checkPath,
73 | sawGroup : sawGroup,
74 | checkGroup : checkGroup
75 | };
76 | if(checkPath != url){
77 | var checkPathGroup={};
78 | for(var t in checkGroup){
79 | var __v=checkGroup[t];
80 | if('{'==__v[0]){
81 | continue;
82 | }
83 |
84 | checkPathGroup[t]= __v;
85 | }
86 | result.checkPathGroup = checkPathGroup;
87 | }
88 | var injectionkey = ['path_','param_','body_','def_','auto_','int_','date_','array_','object_'];
89 | var otherKey ={'req':1,'res':1,'request':1, 'response':1,'callback':1,'cookie':1,'session':1};
90 | for(var i in params){
91 | var param = params[i],
92 | name = param;
93 | metadata = {
94 | sawName : param,
95 | index : i,
96 | type : 'string',
97 | required : true
98 | };
99 |
100 | for(var j in injectionkey){
101 | name=name.replace(injectionkey[j],'');
102 | }
103 |
104 | metadata.name = name;
105 |
106 | if(result[name]!=null)
107 | _error('ParamMetadata register is Has: ',param, url);
108 |
109 | //参数类型处理
110 | if(param.indexOf('date_')>-1){
111 | metadata.type = 'date';
112 | }else if(param.indexOf('object_')>-1){
113 | metadata.type = 'object';
114 | }else if(param.indexOf('array_')>-1){
115 | metadata.type = 'array';
116 | }else if(param.indexOf('int_')>-1){
117 | metadata.type = 'int';
118 | }
119 | //还有其它等等可扩展
120 |
121 | //映射类型处理
122 |
123 | if(otherKey[param] != null ){
124 | metadata.mapType = 'other';
125 | result.otherLength++;
126 | if(result.otherData[name]!=null)
127 | _error('ParamMetadata register is Has: ',param, url);
128 |
129 | if('callback' == param){
130 | result.sync = false;
131 | }
132 | result.otherData[name] = metadata;
133 | continue;
134 | }
135 |
136 | if(param.indexOf('path_')==0){
137 | metadata.mapType = 'path';
138 | result.pathParamLength++;
139 | if(result.pathParamData[name]!=null)
140 | _error('ParamMetadata register is Has: ',param, url);
141 |
142 | var checkKey='{'+name+'}';
143 | var gi=sawGroup.indexOf(checkKey);
144 | if(gi<0)
145 | _error('ParamMetadata register path key not find: ',param, url , checkKey, sawGroup);
146 |
147 | metadata.pathIndex = gi;
148 | result.pathParamData[name] = metadata;
149 |
150 | continue;
151 | }
152 |
153 | if(param.indexOf('param_')==0){
154 | metadata.mapType = 'param';
155 | result.paramLength++;
156 |
157 | if(param.indexOf('def_')<0){
158 | result.checkParamLength++;
159 | metadata.required=false;
160 | }
161 | if(result.paramData[name]!=null)
162 | _error('ParamMetadata register is Has: ',param, url);
163 |
164 | result.paramData[name] = metadata;
165 |
166 | result.queryParams[name] = metadata.required;
167 | continue;
168 | }
169 |
170 | if(param.indexOf('body_')==0){
171 | metadata.mapType = 'body';
172 | if(result.bodyData!=null)
173 | _error('ParamMetadata register is Has: ',param, url);
174 | result.bodyData = metadata;
175 | continue;
176 | }
177 | }
178 |
179 | return result;
180 | },
181 | //public function
182 | register : function(container){
183 |
184 | /***
185 | 1 url 映射处理
186 | 2 参数处理
187 | 3 注入外部上下文
188 | */
189 | for(var sawUrl in container){
190 |
191 | if(sawUrl=='id'){
192 | continue;
193 | }
194 | if(sawUrl.indexOf('auto_')==0){
195 | continue;
196 | }
197 |
198 | var obj = container[sawUrl] ;
199 |
200 | if( obj == null ){
201 | continue;
202 | }
203 |
204 | if(typeof obj !='object'){
205 | continue;
206 | }
207 | if(obj.controller==null){
208 | continue;
209 | }
210 |
211 | var methods=[],
212 | url = null;
213 | if(sawUrl.indexOf(':')<0){
214 | methods=['get'];
215 | url = sawUrl;
216 | }else{
217 | var _urlSplit= sawUrl.split(':');
218 | methods=_urlSplit[0].split('|') ;
219 | url = _urlSplit[1];
220 | }
221 |
222 |
223 | // get paramsMetadata
224 | var controller = obj.controller;
225 | var params = this.getParamNames(controller);
226 | var paramsMetadata = this.getParamMetadata(params,url);
227 | var filter = container.filter;
228 | obj.paramsMetadata = paramsMetadata,
229 | obj.callObjId = container.id;
230 |
231 | for(var i in methods){
232 | var method = methods[i];
233 | var key = this.getKey(method,url,filter);
234 |
235 | if(paramsMetadata.pathParamLength!=0 ){ //有路径变量
236 | key = this.getKey(method,paramsMetadata.checkPath,filter);
237 | var groupNum = paramsMetadata.sawGroup.length;
238 | this.injectionPathMap(groupNum,key,obj);
239 | }else{
240 | //没有路径变量
241 | this.injectionUrlMap(key,obj);
242 | }
243 | //debug("params=====",params,"url=====",url,"paramsMetadata=====",paramsMetadata);
244 | }
245 |
246 | }
247 | },
248 | //过滤成功后执行的回调
249 | filterSuccessCallback : function(req,res,body,statu){
250 | if(res.cookie!=null){
251 | var cookies = res.cookie.valueOf();
252 | res.setHeader('Set-Cookie',cookies);
253 | }
254 | res.writeHead(200, {"Content-Type": "text/plain;charset=utf-8"});
255 | if(body!= null){
256 | if(typeof body == 'string'){
257 | res.write(body);
258 | }else if(typeof body == 'number' ){
259 | res.write(body+"");
260 | }else if(typeof body == 'object'
261 | || Array.isArray(body)
262 | ){
263 | try{
264 | res.write(JSON.stringify(body));
265 | }catch(e){
266 | res.writeHead(500, {"Content-Type": "text/plain;charset=utf-8"});
267 | _error(e.stack,e);
268 | res.write(e.stack);
269 | }
270 | }else{
271 | res.write(body);
272 | }
273 | }
274 | body = null;
275 | res.end();
276 | debug("controller filter : ",'[',req.url,']');
277 | },
278 |
279 | filterProcessor : function(request, response,AppContext){
280 |
281 | var _url = _path.normalize(request.url);
282 | var method = request.method ,
283 | urlObj = queryUrl.parse(_url),
284 | path = urlObj.pathname.trim(),
285 | queryObj = queryString.parse( urlObj.query );
286 |
287 | if(path.lastIndexOf('/') == path.length & path.length!=1){
288 | path = path.substring(0, path.length - 1);
289 | }
290 |
291 | var key=this.getKey(method,path),
292 | groupPath = path.split("/").filter(function(e){return e}) ;
293 | //TODO
294 | //auth check
295 |
296 | var _filter= this._urlData[key];
297 |
298 | if(_filter==null ){
299 | _filter = this.findPathFilter(this._pathData,groupPath);
300 | }
301 |
302 | if(_filter==null ){
303 | _error('not find controller : ' ,key);
304 | return this.auto_requestResultConfig.failuerValueOf();
305 | }
306 |
307 | var queryParams = _filter.queryParams;
308 |
309 | //check params
310 | for(var key in queryParams){
311 | var flag = queryParams[key];
312 | if(queryObj[key]==null && flag){
313 | _error(' params is not : ',queryParams,'[',_url,']','[',_filter.callObjId,']');
314 | return this.auto_requestResultConfig.failuerValueOf();
315 | }
316 | }
317 | //param is right
318 | //injection path
319 | //injection param
320 | //injection paramAndPath
321 | //injection other
322 |
323 | var callParams=[],
324 | resultMap = {},
325 | callObjId = _filter.callObjId,
326 | controller = _filter.controller,
327 | paramsMetadata = _filter.paramsMetadata,
328 | sync = paramsMetadata.sync;
329 |
330 | for(var name in paramsMetadata.pathParamData){
331 | var metadata = paramsMetadata.pathParamData[name];
332 | this.injectionParamProcess(request, response,AppContext,metadata,queryObj,groupPath,resultMap);
333 | }
334 |
335 | //paramData
336 | for(var name in paramsMetadata.paramData){
337 | var metadata = paramsMetadata.paramData[name];
338 | this.injectionParamProcess(request, response,AppContext,metadata,queryObj,null,resultMap);
339 | }
340 |
341 | //bodyData
342 | if(paramsMetadata.bodyData!=null){
343 | this.injectionParamProcess(request, response,AppContext,paramsMetadata.bodyData,queryObj,null,resultMap);
344 | }
345 | //otherData
346 | for(var name in paramsMetadata.otherData){
347 | var metadata = paramsMetadata.otherData[name];
348 | this.injectionParamProcess(request, response,AppContext,metadata,queryObj,null,resultMap);
349 | }
350 |
351 | //sort
352 | for(var k in resultMap){
353 | callParams.push(k);
354 | }
355 | for(var i in callParams){
356 | callParams[i]=resultMap[i];
357 | }
358 |
359 | var callObj = AppContext.findContainer(callObjId);
360 | if(callObj == null){
361 | callObj = _filter;
362 | }
363 | //debug('callObjId ==============',callObjId);
364 | //debug('callParams ==============',callParams);
365 | //debug(" sync ===========================",sync);
366 | var result = controller.apply(callObj,callParams);
367 | if(sync){
368 | return this.auto_requestResultConfig.successValueOf(result);
369 | }else{
370 | return this.auto_requestResultConfig.callbackValueOf();
371 | }
372 | },
373 |
374 |
375 | //private function
376 | findPathFilter : function(data,groupPath){
377 | var _ar = data[groupPath.length];
378 |
379 | if(_ar==null) return null;
380 | var _filter =null;
381 | //debug("findPathFilter======", data,groupPath);
382 | //debug("findPathFilter======", _ar);
383 | for(var i in _ar){
384 | var _f = _ar[i];
385 | var paramsMetadata = _f.paramsMetadata,
386 | flag = true,
387 | checkPathGroup = paramsMetadata.checkPathGroup;
388 |
389 |
390 | for(var j in checkPathGroup){
391 | var checkValue = checkPathGroup[j];
392 | if( checkValue != groupPath[j] ){
393 | flag = false;
394 | break;
395 | }
396 | }
397 | //debug("findPathFilter======", checkPathGroup,groupPath,flag);
398 |
399 | if(flag){
400 | _filter = _f;
401 | break;
402 | }
403 | }
404 |
405 | return _filter;
406 | },
407 |
408 | injectionParamProcess : function(request, response,AppContext,metadata,queryObj,groupPath,resultMap){
409 | var index = metadata.index,
410 | name = metadata.name,
411 | type = metadata.type,
412 | mapType = metadata.mapType,
413 | required = metadata.required,
414 | value=null;
415 |
416 | var $this = this;
417 | if(response.cookie == null){
418 | response.cookie ={
419 | cookieData : $this.auto_cookie.parse( (request.headers.cookie || '') ) ,
420 |
421 | set : function(key , value , opt){
422 | this.cookieData[key]={
423 | value : value,
424 | opt : opt
425 | };
426 | },
427 | get : function(key){
428 | var cookie = this.cookieData[key];
429 | if(cookie == null)
430 | return null;
431 |
432 | return cookie.value;
433 | },
434 | remove : function(key){
435 | this.set(key,null,{
436 | expires : -1
437 | });
438 | },
439 | valueOf : function(){
440 | var result =[];
441 | for( var key in this.cookieData){
442 | var cookie = this.cookieData[key];
443 | var str = $this.auto_cookie.serialize(key, cookie.value, cookie.opt);
444 | result.push(str) ;
445 | }
446 |
447 | return result;
448 | }
449 | };
450 | }
451 | switch(mapType){
452 | case 'param' :
453 | value = queryObj[name];
454 | if(value==null && required){
455 | //TODO throw
456 | _error('injectionParam parram is null : ',name);
457 | }
458 | break;
459 | case 'path' :
460 | var pathIndex = metadata.pathIndex;
461 | value = groupPath[pathIndex];
462 | if(value==null){
463 | //TODO throw
464 | _error('injectionParam path is null : ',name);
465 | }
466 | break;
467 | case 'body' :
468 | value = queryObj;
469 | break;
470 | case 'other' :
471 | //debug(value," other value +++++++++++");
472 | switch(name){
473 | case 'callback' :
474 | value = function(result){ $this.filterSuccessCallback(request,response,result) ;};
475 | break;
476 | case 'session' :
477 | var sid = response.cookie.get(SessionKey.uuid);
478 | var session = $this.auto_sessionManager.getSession(sid);
479 | if(session == null){
480 | //TODO throw
481 | _error('injectionParam session is null : ',sid);
482 | }
483 | value = session;
484 | break;
485 | case 'cookie' :
486 | value = response.cookie ;
487 | break;
488 | default :
489 | var otherKey ={'req':request,'res':response,'request':request, 'response':response};
490 | value = otherKey[name];
491 | otherKey = null;
492 | break;
493 | }
494 |
495 | break;
496 | }
497 | if(value!=null ){
498 | switch(mapType){
499 | case 'path' :
500 | case 'param' :
501 |
502 | switch(type){
503 | case 'int' :
504 | var _v=parseInt(value);
505 | if(isNaN(_v) ){
506 | //TODO throw
507 | _error('injectionParam parram num is null : ',name,value);
508 | }
509 | value=_v;
510 | break;
511 | case 'array' :
512 | if(!Array.isArray(value)){
513 | value=[value];
514 | }
515 | break;
516 | case 'date' :
517 | value=dateConverter.convert(value);
518 | break;
519 | }
520 | break;
521 | }
522 | }
523 |
524 |
525 | resultMap[index] = value;
526 | },
527 |
528 | injectionPathMap : function(groupNum,key,controller){
529 | if(this._pathData[groupNum]==null){
530 | this._pathData[groupNum] = {};
531 | }
532 | this._pathData[groupNum][key]!=null
533 | && _error("重复注册 REST injectionPathMap 处理器 : " ,key);
534 | debug("injectionPathMap : ",key);
535 |
536 | this._pathData[groupNum][key]=controller;
537 | },
538 | injectionUrlMap : function(key,controller){
539 | this._urlData[key]!=null
540 | && _error("重复注册 REST injectionUrlMap 处理器 : " ,key);
541 | debug("injectionUrlMap : ",key);
542 |
543 | this._urlData[key]=controller;
544 | },
545 |
546 | getMapSize : function(map){
547 | var num=0;
548 | for(var i in map) num++;
549 | return num;
550 | },
551 | //cp google
552 | getParamNames : function(func) {
553 | var fnStr = func.toString().replace(STRIP_COMMENTS, '')
554 | var result = fnStr.slice(fnStr.indexOf('(')+1, fnStr.indexOf(')')).match(/([^\s,]+)/g)
555 | if(result === null)
556 | result = []
557 | return result
558 | },
559 | getKey : function(method,url,filter){
560 | url=_path.normalize(url);
561 | if(url.lastIndexOf('/') == url.length && url.length!=1){
562 | url = key.substring(0, url.length - 1);
563 | }
564 | if(filter==null) filter='';
565 | return method.toLowerCase().trim() + "_"+ filter +url.toLowerCase().trim();
566 | },
567 | };
568 |
569 | module.exports = requestController;
--------------------------------------------------------------------------------
/core/RequestFilterProcessor.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * 总url入口拦截处理器
5 | * */
6 | var fs = require('fs'),
7 | queryUrl = require('url'),
8 | _path = require('path'),
9 | _error = require('../core/util/debug.js').error;
10 | debug = require('../core/util/debug.js').debug;
11 |
12 |
13 | module.exports = {
14 | auto_appConfig : null,
15 | auto_requestResultConfig : null,
16 | injectionType : 'core',
17 | filterProcessor : [],
18 | awake : function(AppContext){
19 | var $this=this;
20 | AppContext.findInjectionOfType(['filter'],null,function(container){
21 | $this.register(container);
22 | });
23 | this.sort();
24 | },
25 | sort : function(){
26 | this.filterProcessor.sort(function(a,b){
27 | if(a.order==null) return -1;
28 | if(b.order==null) return -1;
29 |
30 | return a.order1){
35 | callBack(commonds.slice(1,commonds.length));
36 | }else{
37 | callBack();
38 | }
39 | return;
40 | }
41 |
42 | /*
43 | switch(commonds[0]){
44 | case 'exit':
45 | process.exit(0);
46 | break;
47 | }
48 | */
49 | });
50 |
51 | process.on('exit', function(code) {
52 | $this.end();
53 | console.log('exit with code:', code);
54 | });
55 | },
56 | end : function(){
57 | //stdin.end();
58 | //decoder.end();
59 | }
60 | }
--------------------------------------------------------------------------------
/core/exception/Exception.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solq360/springnodejs/c3113229d03ca102ae18b3b4f8d06f1a40adeb8d/core/exception/Exception.js
--------------------------------------------------------------------------------
/core/session/SessionContext.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 |
6 | module.exports = {
7 | injectionType : 'config',
8 | //回收会话时间
9 | gcTime : 1000*60 *15,
10 | //心跳保持时间
11 | hbTime : 1000*2,
12 | //每个会话消息保存长度
13 | msgMaxLength : 50,
14 | //当超过上限时把一个提下来
15 | //支持同一账号多个会话
16 | maxSession : 5
17 | };
18 |
--------------------------------------------------------------------------------
/core/session/SessionKey.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 |
6 | global.SessionKey = {
7 | lastTime : 'lastTime', //最后访问时间
8 | bind : 'bind', //绑定对象
9 | state : 'state', //会话状态
10 | uuid : 'uuid', //返回 cookie uuid
11 | };
12 |
--------------------------------------------------------------------------------
/core/session/SessionManager.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 | var debug = require('../../core/util/debug.js').debug,
6 | _error = require('../../core/util/debug.js').error;
7 |
8 | module.exports = {
9 | auto_sessionContext : null,
10 | injectionType : 'core',
11 |
12 | awake : function(){
13 | this.initSessionGCProcessor();
14 | this.intiSessionHeartbeatProcessor();
15 | //test
16 | /*
17 | try{
18 | this.createSession(56565);
19 | this.createSession(56565);
20 | this.createSession(56565);
21 | this.createSession(56565);
22 | this.createSession(56565);
23 | this.createSession(56565);
24 | this.createSession(56565);
25 | }catch(er){
26 | debug(er);
27 | } */
28 | //debug("createSession =====",this._data);
29 | },
30 | _data : {}, //保存会话
31 | _bind : {}, //绑定对象
32 | /** 会话基本操作 ***/
33 | //查找会话
34 | getSession : function(id){
35 | return this._data[id];
36 | },
37 | //创建会话
38 | createSession : function(bid){
39 | //check max session
40 | var _bind_array = this._bind[bid];
41 | if(_bind_array == null){
42 | this._bind[bid] = [];
43 | }else if(_bind_array.length> this.auto_sessionContext.maxSession ){
44 | //todo throw
45 | throw Exception.valueOf('max bind session :'+bid, Exception.ERROR_MAX_SESSION);
46 | }
47 |
48 | var uuid = this.getUUID().replace(/-/mg,'');
49 | this._bind[bid].push(uuid);
50 |
51 | var $this = this;
52 | var session = {
53 | id: uuid,
54 | //state : 1, //会话状态
55 | //bid : bid, //绑定ID
56 | //lastTime : new Date(), //最后访问时间
57 | _attr :{}, //属性
58 | _msg : [], //保存推送消息
59 | getAllAttr : function(){ return this._attr; },
60 | getAttr : function(key){ return this._attr[key]; }, //获取属性
61 | removeAttr : function(key){ this._attr[key]=null ; }, //删除属性
62 | setAttr : function(key,value){ this._attr[key] = value; return this; }, //设置属性
63 | write : function(msg){ this._msg.push(msg); }, //输入准备推送的消息
64 | getAndPushMsg : function(){ var result = this._msg; this._msg = []; return result; }, //获取并且推送消息
65 | close : function(){ this.setAttr(SessionKey.state,0); }, //关闭会话
66 | destory : function(){ this.setAttr(SessionKey.state,-1); }, //销毁会话
67 | replace : function(session){ var allAttr =session.getAllAttr() ; for(var key in allAttr) this._attr[key] ==null && this._attr[key]=allAttr[key]; }, //替换会话
68 | refreshLastTime : function(){ //刷新最后访问时间
69 | this.setAttr(SessionKey.lastTime,new Date())
70 | .setAttr(SessionKey.state,1);
71 | },
72 | init : function(bid){ //初始化
73 | this
74 | .setAttr(SessionKey.lastTime,new Date())
75 | .setAttr(SessionKey.bind,bid)
76 | .setAttr(SessionKey.state,1);
77 | },
78 | };
79 | session.init(bid);
80 | this._data[session.id] = session;
81 | return session;
82 | },
83 | //替换会话
84 | replaceSession : function(source,target){
85 | var newSession = this.getSession(source),
86 | oldSession = this.getSession(target);
87 |
88 | if(newSession !=null && oldSession!=null){
89 | newSession.replace(oldSession);
90 | this.destorySession(oldSession.id);
91 | }
92 | },
93 | //销毁会话
94 | destorySession : function(id){
95 | var session = this.getSession(id);
96 | if(session !=null){
97 | session.destory();
98 | delete this._data[id];
99 | //删除绑定
100 | var bid = session.getAttr(SessionKey.bind);
101 | if(this._bind[bid]!=null){
102 | var index = this._bind[bid].indexOf(id);
103 | //debug("remove bid: ================",bid ," index : ",index);
104 | if(index >-1){
105 | this._bind[bid].splice(index, 1);
106 | //debug("remove : ================",id);
107 | }
108 | }
109 | }
110 | },
111 | //共享会话
112 | sharedSession : function(){},
113 |
114 | /** 会话处理器 ***/
115 | //初始化会话回收处理器
116 | initSessionGCProcessor : function(){
117 | var $this = this,
118 | time = this.auto_sessionContext.gcTime;
119 | setInterval(function(){
120 | var now = new Date().getTime();
121 | var removeSessions = [];
122 | //find remove
123 | for(var i in $this._data){
124 | var session = $this._data[i],
125 | state = session.getAttr(SessionKey.state),
126 | lastTime = session.getAttr(SessionKey.lastTime);
127 | if( (lastTime.getTime()+time ) < now ){
128 | removeSessions.push( session.id );
129 | }
130 | }
131 | //debug("remove session bind: ",this._bind);
132 |
133 | //debug("run gc :",removeSessions);
134 | //now remove
135 | for(var i in removeSessions){
136 | $this.destorySession(removeSessions[i]);
137 | }
138 | },time);
139 | },
140 | //初始化会话心跳检测处理器
141 | intiSessionHeartbeatProcessor : function(){},
142 | //推送消息处理器
143 | pushMessageProcessor : function(id){
144 | var session = this.getSession(id);
145 | if(session ==null) return null;
146 | return session.getAndPushMsg();
147 | },
148 | getUUID : function(){
149 | function s4() {
150 | return Math.floor((1 + Math.random()) * 0x10000)
151 | .toString(16)
152 | .substring(1);
153 | }
154 | return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
155 | s4() + '-' + s4() + s4() + s4();
156 | }
157 | };
158 |
--------------------------------------------------------------------------------
/core/session/cookie.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 | /// Serialize the a name value pair into a cookie string suitable for
6 | /// http headers. An optional options object specified cookie parameters
7 | ///
8 | /// serialize('foo', 'bar', { httpOnly: true })
9 | /// => "foo=bar; httpOnly"
10 | ///
11 | /// @param {String} name
12 | /// @param {String} val
13 | /// @param {Object} options
14 | /// @return {String}
15 |
16 | /// Parse the given cookie header string into an object
17 | /// The object has the various cookies as keys(names) => values
18 | /// @param {String} str
19 | /// @return {Object}
20 |
21 | var encode = encodeURIComponent;
22 | var decode = decodeURIComponent;
23 |
24 | module.exports ={
25 | def_opt : {
26 | httpOnly : true,
27 | expires : 1000*60 *60*24 * 30
28 | },
29 | serialize : function(name, val, opt){
30 | opt = opt || this.def_opt;
31 | var enc = opt.encode || encode;
32 | var pairs = [name + '=' + enc(val)];
33 |
34 | if (null != opt.maxAge) {
35 | var maxAge = opt.maxAge - 0;
36 | if (isNaN(maxAge)) throw new Error('maxAge should be a Number');
37 | pairs.push('max-Age=' + maxAge);
38 | }
39 | //console.log("typeof opt.expires =='date'", typeof opt.expires);
40 | if (opt.domain) pairs.push('domain=' + opt.domain);
41 | if (opt.path) pairs.push('path=' + opt.path);
42 | if (opt.expires) {
43 | if(typeof opt.expires =='number'){
44 | var time = opt.expires ;
45 | if( opt.expires >0 ){
46 | time = new Date().getTime() + opt.expires ;
47 | }
48 | pairs.push('expires=' + new Date(time ).toUTCString() );
49 | }else{
50 | pairs.push('expires=' + opt.expires.toUTCString() );
51 | }
52 | }
53 | if (opt.httpOnly) pairs.push('httpOnly');
54 | if (opt.secure) pairs.push('secure');
55 |
56 | return pairs.join('; ');
57 | },
58 | parse : function(str, opt) {
59 | opt = opt || {};
60 | var obj = {}
61 | var pairs = str.split(/; */);
62 | var dec = opt.decode || decode
63 |
64 |
65 | pairs.forEach(function(pair) {
66 | var eq_idx = pair.indexOf('=')
67 |
68 | // skip things that don't look like key=value
69 | if (eq_idx < 0) {
70 | return;
71 | }
72 |
73 | var key = pair.substr(0, eq_idx).trim()
74 | var val = pair.substr(++eq_idx, pair.length).trim();
75 |
76 | // quoted values
77 | if ('"' == val[0]) {
78 | val = val.slice(1, -1);
79 | }
80 |
81 | // only assign once
82 | if (undefined == obj[key]) {
83 | try {
84 | obj[key] = {
85 | value : dec(val)
86 | } ;
87 | } catch (e) {
88 | obj[key] ={
89 | value : val
90 | } ;
91 | }
92 | }
93 | });
94 |
95 | return obj;
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/core/util/WebHelper.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 | var fs = require("fs"),
6 | _path = require("path");
7 |
8 | function walk(dir,suffix) {
9 | var results = []
10 | var list = fs.readdirSync(dir)
11 | list.forEach(function(file) {
12 | file = dir + '/' + file
13 | var stat = fs.statSync(file)
14 | if (stat && stat.isDirectory()){
15 | results = results.concat(walk(file,suffix))
16 | }
17 | else {
18 | if(suffix!=null){
19 | if(suffix!=_path.extname(file)){
20 | return;
21 | }
22 | }
23 | results.push(file)
24 | }
25 | })
26 | return results
27 | }
28 | module.exports = {
29 |
30 | scanProcess : function(scanConfig,suffix,callFn){
31 | for(var dir in scanConfig){
32 | var files = walk(dir,suffix),
33 | obj = scanConfig[dir];
34 |
35 | for(var i in files){
36 | var filePath=files[i];
37 |
38 | if(obj.include!=null){
39 | if(obj.include.indexOf(filePath)<0){
40 | continue;
41 | }
42 | }
43 |
44 | if(obj.exclude!=null){
45 | if(obj.exclude.indexOf(filePath)>-1){
46 | continue;
47 | }
48 | }
49 | callFn(filePath,obj);
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/core/util/dateConverter.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 | var dateConverter = {},
6 | dateConfig=[
7 | "yyyy-MM",
8 | "yyyy-MM-dd",
9 | "yyyy-MM-dd HH:mm:ss",
10 | "HH:mm:ss",
11 | ];
12 | for(var i in dateConfig){
13 | var key = dateConfig[i].length;
14 | dateConverter[key]= dateConfig[i];
15 | }
16 | module.exports = {
17 | dateConverter : dateConverter,
18 | convert : function(str_date){
19 | //var key = str_date.length;
20 | //var config = this.dateConverter[key];
21 |
22 | return new Date(Date.parse(str_date.replace(/-/g, "/")))
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/core/util/debug.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 | var appConfig = require('../../config/AppConfig.js');
6 | module.exports = {
7 | debug : function(){
8 | (appConfig.LOGDEBUG & appConfig.LOGLEVEL) &&
9 | console.log.apply(console, arguments);
10 | },
11 | error : function(){
12 | (appConfig.LOGERROR & appConfig.LOGLEVEL) &&
13 | console.error.apply(console, arguments);
14 | },
15 | info : function(){
16 | (appConfig.LOGINFO & appConfig.LOGLEVEL) &&
17 | console.info.apply(console, arguments);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 | hello welcome to my spring nodejs
2 | blog: cnblogs.com/solq
3 | www.springnodejs.com
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "springnodejs",
3 | "version": "0.0.5",
4 | "description": "springnodejs",
5 | "main": "app.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "repository": {
10 | "type": "git",
11 | "url": "https://github.com/solq360/springnodejs"
12 | },
13 | "keywords": [
14 | "springnodejs",
15 | "springjs",
16 | "spring",
17 | "rest",
18 | "ioc",
19 | "aop"
20 | ],
21 | "author": "solq",
22 | "license": "GPL-3.0",
23 | "bugs": {
24 | "url": "https://github.com/solq360/springnodejs/issues"
25 | },
26 | "homepage": "https://github.com/solq360/springnodejs"
27 | }
28 |
--------------------------------------------------------------------------------
/plugs/mime/mime.js:
--------------------------------------------------------------------------------
1 | var path = require('path');
2 | var fs = require('fs');
3 |
4 | function Mime() {
5 | // Map of extension -> mime type
6 | this.types = Object.create(null);
7 |
8 | // Map of mime type -> extension
9 | this.extensions = Object.create(null);
10 | }
11 |
12 | /**
13 | * Define mimetype -> extension mappings. Each key is a mime-type that maps
14 | * to an array of extensions associated with the type. The first extension is
15 | * used as the default extension for the type.
16 | *
17 | * e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
18 | *
19 | * @param map (Object) type definitions
20 | */
21 | Mime.prototype.define = function (map) {
22 | for (var type in map) {
23 | var exts = map[type];
24 |
25 | for (var i = 0; i < exts.length; i++) {
26 | if (process.env.DEBUG_MIME && this.types[exts]) {
27 | console.warn(this._loading.replace(/.*\//, ''), 'changes "' + exts[i] + '" extension type from ' +
28 | this.types[exts] + ' to ' + type);
29 | }
30 |
31 | this.types[exts[i]] = type;
32 | }
33 |
34 | // Default extension is the first one we encounter
35 | if (!this.extensions[type]) {
36 | this.extensions[type] = exts[0];
37 | }
38 | }
39 | };
40 |
41 | /**
42 | * Load an Apache2-style ".types" file
43 | *
44 | * This may be called multiple times (it's expected). Where files declare
45 | * overlapping types/extensions, the last file wins.
46 | *
47 | * @param file (String) path of file to load.
48 | */
49 | Mime.prototype.load = function(file) {
50 |
51 | this._loading = file;
52 | // Read file and split into lines
53 | var map = {},
54 | content = fs.readFileSync(file, 'ascii'),
55 | lines = content.split(/[\r\n]+/);
56 |
57 | lines.forEach(function(line) {
58 | // Clean up whitespace/comments, and split into fields
59 | var fields = line.replace(/\s*#.*|^\s*|\s*$/g, '').split(/\s+/);
60 | map[fields.shift()] = fields;
61 | });
62 |
63 | this.define(map);
64 |
65 | this._loading = null;
66 | };
67 |
68 | /**
69 | * Lookup a mime type based on extension
70 | */
71 | Mime.prototype.lookup = function(path, fallback) {
72 | var ext = path.replace(/.*[\.\/\\]/, '').toLowerCase();
73 |
74 | return this.types[ext] || fallback || this.default_type;
75 | };
76 |
77 | /**
78 | * Return file extension associated with a mime type
79 | */
80 | Mime.prototype.extension = function(mimeType) {
81 | var type = mimeType.match(/^\s*([^;\s]*)(?:;|\s|$)/)[1].toLowerCase();
82 | return this.extensions[type];
83 | };
84 |
85 | // Default instance
86 | var mime = new Mime();
87 |
88 | // Load local copy of
89 | // http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
90 | mime.load(path.join(__dirname, 'types/mime.types'));
91 |
92 | // Load additional types from node.js community
93 | mime.load(path.join(__dirname, 'types/node.types'));
94 |
95 | // Default type
96 | mime.default_type = mime.lookup('bin');
97 |
98 | //
99 | // Additional API specific to the default instance
100 | //
101 |
102 | mime.Mime = Mime;
103 |
104 | /**
105 | * Lookup a charset based on mime type.
106 | */
107 | mime.charsets = {
108 | lookup: function(mimeType, fallback) {
109 | // Assume text types are utf8
110 | return (/^text\//).test(mimeType) ? 'UTF-8' : fallback;
111 | }
112 | };
113 |
114 | module.exports = mime;
115 |
--------------------------------------------------------------------------------
/plugs/mime/test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Usage: node test.js
3 | */
4 |
5 | var mime = require('./mime');
6 | var assert = require('assert');
7 | var path = require('path');
8 |
9 | function eq(a, b) {
10 | console.log('Test: ' + a + ' === ' + b);
11 | assert.strictEqual.apply(null, arguments);
12 | }
13 |
14 | console.log(Object.keys(mime.extensions).length + ' types');
15 | console.log(Object.keys(mime.types).length + ' extensions\n');
16 |
17 | //
18 | // Test mime lookups
19 | //
20 |
21 | eq('text/plain', mime.lookup('text.txt')); // normal file
22 | eq('text/plain', mime.lookup('TEXT.TXT')); // uppercase
23 | eq('text/plain', mime.lookup('dir/text.txt')); // dir + file
24 | eq('text/plain', mime.lookup('.text.txt')); // hidden file
25 | eq('text/plain', mime.lookup('.txt')); // nameless
26 | eq('text/plain', mime.lookup('txt')); // extension-only
27 | eq('text/plain', mime.lookup('/txt')); // extension-less ()
28 | eq('text/plain', mime.lookup('\\txt')); // Windows, extension-less
29 | eq('application/octet-stream', mime.lookup('text.nope')); // unrecognized
30 | eq('fallback', mime.lookup('text.fallback', 'fallback')); // alternate default
31 |
32 | //
33 | // Test extensions
34 | //
35 |
36 | eq('txt', mime.extension(mime.types.text));
37 | eq('html', mime.extension(mime.types.htm));
38 | eq('bin', mime.extension('application/octet-stream'));
39 | eq('bin', mime.extension('application/octet-stream '));
40 | eq('html', mime.extension(' text/html; charset=UTF-8'));
41 | eq('html', mime.extension('text/html; charset=UTF-8 '));
42 | eq('html', mime.extension('text/html; charset=UTF-8'));
43 | eq('html', mime.extension('text/html ; charset=UTF-8'));
44 | eq('html', mime.extension('text/html;charset=UTF-8'));
45 | eq('html', mime.extension('text/Html;charset=UTF-8'));
46 | eq(undefined, mime.extension('unrecognized'));
47 |
48 | //
49 | // Test node.types lookups
50 | //
51 |
52 | eq('application/font-woff', mime.lookup('file.woff'));
53 | eq('application/octet-stream', mime.lookup('file.buffer'));
54 | eq('audio/mp4', mime.lookup('file.m4a'));
55 | eq('font/opentype', mime.lookup('file.otf'));
56 |
57 | //
58 | // Test charsets
59 | //
60 |
61 | eq('UTF-8', mime.charsets.lookup('text/plain'));
62 | eq(undefined, mime.charsets.lookup(mime.types.js));
63 | eq('fallback', mime.charsets.lookup('application/octet-stream', 'fallback'));
64 |
65 | //
66 | // Test for overlaps between mime.types and node.types
67 | //
68 |
69 | var apacheTypes = new mime.Mime(), nodeTypes = new mime.Mime();
70 | apacheTypes.load(path.join(__dirname, 'types/mime.types'));
71 | nodeTypes.load(path.join(__dirname, 'types/node.types'));
72 |
73 | var keys = [].concat(Object.keys(apacheTypes.types))
74 | .concat(Object.keys(nodeTypes.types));
75 | keys.sort();
76 | for (var i = 1; i < keys.length; i++) {
77 | if (keys[i] == keys[i-1]) {
78 | console.warn('Warning: ' +
79 | 'node.types defines ' + keys[i] + '->' + nodeTypes.types[keys[i]] +
80 | ', mime.types defines ' + keys[i] + '->' + apacheTypes.types[keys[i]]);
81 | }
82 | }
83 |
84 | console.log('\nOK');
85 |
--------------------------------------------------------------------------------
/plugs/mime/types/mime.types:
--------------------------------------------------------------------------------
1 | # This file maps Internet media types to unique file extension(s).
2 | # Although created for httpd, this file is used by many software systems
3 | # and has been placed in the public domain for unlimited redisribution.
4 | #
5 | # The table below contains both registered and (common) unregistered types.
6 | # A type that has no unique extension can be ignored -- they are listed
7 | # here to guide configurations toward known types and to make it easier to
8 | # identify "new" types. File extensions are also commonly used to indicate
9 | # content languages and encodings, so choose them carefully.
10 | #
11 | # Internet media types should be registered as described in RFC 4288.
12 | # The registry is at .
13 | #
14 | # MIME type (lowercased) Extensions
15 | # ============================================ ==========
16 | # application/1d-interleaved-parityfec
17 | # application/3gpp-ims+xml
18 | # application/activemessage
19 | application/andrew-inset ez
20 | # application/applefile
21 | application/applixware aw
22 | application/atom+xml atom
23 | application/atomcat+xml atomcat
24 | # application/atomicmail
25 | application/atomsvc+xml atomsvc
26 | # application/auth-policy+xml
27 | # application/batch-smtp
28 | # application/beep+xml
29 | # application/calendar+xml
30 | # application/cals-1840
31 | # application/ccmp+xml
32 | application/ccxml+xml ccxml
33 | application/cdmi-capability cdmia
34 | application/cdmi-container cdmic
35 | application/cdmi-domain cdmid
36 | application/cdmi-object cdmio
37 | application/cdmi-queue cdmiq
38 | # application/cea-2018+xml
39 | # application/cellml+xml
40 | # application/cfw
41 | # application/cnrp+xml
42 | # application/commonground
43 | # application/conference-info+xml
44 | # application/cpl+xml
45 | # application/csta+xml
46 | # application/cstadata+xml
47 | application/cu-seeme cu
48 | # application/cybercash
49 | application/davmount+xml davmount
50 | # application/dca-rft
51 | # application/dec-dx
52 | # application/dialog-info+xml
53 | # application/dicom
54 | # application/dns
55 | application/docbook+xml dbk
56 | # application/dskpp+xml
57 | application/dssc+der dssc
58 | application/dssc+xml xdssc
59 | # application/dvcs
60 | application/ecmascript ecma
61 | # application/edi-consent
62 | # application/edi-x12
63 | # application/edifact
64 | application/emma+xml emma
65 | # application/epp+xml
66 | application/epub+zip epub
67 | # application/eshop
68 | # application/example
69 | application/exi exi
70 | # application/fastinfoset
71 | # application/fastsoap
72 | # application/fits
73 | application/font-tdpfr pfr
74 | # application/framework-attributes+xml
75 | application/gml+xml gml
76 | application/gpx+xml gpx
77 | application/gxf gxf
78 | # application/h224
79 | # application/held+xml
80 | # application/http
81 | application/hyperstudio stk
82 | # application/ibe-key-request+xml
83 | # application/ibe-pkg-reply+xml
84 | # application/ibe-pp-data
85 | # application/iges
86 | # application/im-iscomposing+xml
87 | # application/index
88 | # application/index.cmd
89 | # application/index.obj
90 | # application/index.response
91 | # application/index.vnd
92 | application/inkml+xml ink inkml
93 | # application/iotp
94 | application/ipfix ipfix
95 | # application/ipp
96 | # application/isup
97 | application/java-archive jar
98 | application/java-serialized-object ser
99 | application/java-vm class
100 | application/javascript js
101 | application/json json
102 | application/jsonml+json jsonml
103 | # application/kpml-request+xml
104 | # application/kpml-response+xml
105 | application/lost+xml lostxml
106 | application/mac-binhex40 hqx
107 | application/mac-compactpro cpt
108 | # application/macwriteii
109 | application/mads+xml mads
110 | application/marc mrc
111 | application/marcxml+xml mrcx
112 | application/mathematica ma nb mb
113 | # application/mathml-content+xml
114 | # application/mathml-presentation+xml
115 | application/mathml+xml mathml
116 | # application/mbms-associated-procedure-description+xml
117 | # application/mbms-deregister+xml
118 | # application/mbms-envelope+xml
119 | # application/mbms-msk+xml
120 | # application/mbms-msk-response+xml
121 | # application/mbms-protection-description+xml
122 | # application/mbms-reception-report+xml
123 | # application/mbms-register+xml
124 | # application/mbms-register-response+xml
125 | # application/mbms-user-service-description+xml
126 | application/mbox mbox
127 | # application/media_control+xml
128 | application/mediaservercontrol+xml mscml
129 | application/metalink+xml metalink
130 | application/metalink4+xml meta4
131 | application/mets+xml mets
132 | # application/mikey
133 | application/mods+xml mods
134 | # application/moss-keys
135 | # application/moss-signature
136 | # application/mosskey-data
137 | # application/mosskey-request
138 | application/mp21 m21 mp21
139 | application/mp4 mp4s
140 | # application/mpeg4-generic
141 | # application/mpeg4-iod
142 | # application/mpeg4-iod-xmt
143 | # application/msc-ivr+xml
144 | # application/msc-mixer+xml
145 | application/msword doc dot
146 | application/mxf mxf
147 | # application/nasdata
148 | # application/news-checkgroups
149 | # application/news-groupinfo
150 | # application/news-transmission
151 | # application/nss
152 | # application/ocsp-request
153 | # application/ocsp-response
154 | application/octet-stream bin dms lrf mar so dist distz pkg bpk dump elc deploy
155 | application/oda oda
156 | application/oebps-package+xml opf
157 | application/ogg ogx
158 | application/omdoc+xml omdoc
159 | application/onenote onetoc onetoc2 onetmp onepkg
160 | application/oxps oxps
161 | # application/parityfec
162 | application/patch-ops-error+xml xer
163 | application/pdf pdf
164 | application/pgp-encrypted pgp
165 | # application/pgp-keys
166 | application/pgp-signature asc sig
167 | application/pics-rules prf
168 | # application/pidf+xml
169 | # application/pidf-diff+xml
170 | application/pkcs10 p10
171 | application/pkcs7-mime p7m p7c
172 | application/pkcs7-signature p7s
173 | application/pkcs8 p8
174 | application/pkix-attr-cert ac
175 | application/pkix-cert cer
176 | application/pkix-crl crl
177 | application/pkix-pkipath pkipath
178 | application/pkixcmp pki
179 | application/pls+xml pls
180 | # application/poc-settings+xml
181 | application/postscript ai eps ps
182 | # application/prs.alvestrand.titrax-sheet
183 | application/prs.cww cww
184 | # application/prs.nprend
185 | # application/prs.plucker
186 | # application/prs.rdf-xml-crypt
187 | # application/prs.xsf+xml
188 | application/pskc+xml pskcxml
189 | # application/qsig
190 | application/rdf+xml rdf
191 | application/reginfo+xml rif
192 | application/relax-ng-compact-syntax rnc
193 | # application/remote-printing
194 | application/resource-lists+xml rl
195 | application/resource-lists-diff+xml rld
196 | # application/riscos
197 | # application/rlmi+xml
198 | application/rls-services+xml rs
199 | application/rpki-ghostbusters gbr
200 | application/rpki-manifest mft
201 | application/rpki-roa roa
202 | # application/rpki-updown
203 | application/rsd+xml rsd
204 | application/rss+xml rss
205 | application/rtf rtf
206 | # application/rtx
207 | # application/samlassertion+xml
208 | # application/samlmetadata+xml
209 | application/sbml+xml sbml
210 | application/scvp-cv-request scq
211 | application/scvp-cv-response scs
212 | application/scvp-vp-request spq
213 | application/scvp-vp-response spp
214 | application/sdp sdp
215 | # application/set-payment
216 | application/set-payment-initiation setpay
217 | # application/set-registration
218 | application/set-registration-initiation setreg
219 | # application/sgml
220 | # application/sgml-open-catalog
221 | application/shf+xml shf
222 | # application/sieve
223 | # application/simple-filter+xml
224 | # application/simple-message-summary
225 | # application/simplesymbolcontainer
226 | # application/slate
227 | # application/smil
228 | application/smil+xml smi smil
229 | # application/soap+fastinfoset
230 | # application/soap+xml
231 | application/sparql-query rq
232 | application/sparql-results+xml srx
233 | # application/spirits-event+xml
234 | application/srgs gram
235 | application/srgs+xml grxml
236 | application/sru+xml sru
237 | application/ssdl+xml ssdl
238 | application/ssml+xml ssml
239 | # application/tamp-apex-update
240 | # application/tamp-apex-update-confirm
241 | # application/tamp-community-update
242 | # application/tamp-community-update-confirm
243 | # application/tamp-error
244 | # application/tamp-sequence-adjust
245 | # application/tamp-sequence-adjust-confirm
246 | # application/tamp-status-query
247 | # application/tamp-status-response
248 | # application/tamp-update
249 | # application/tamp-update-confirm
250 | application/tei+xml tei teicorpus
251 | application/thraud+xml tfi
252 | # application/timestamp-query
253 | # application/timestamp-reply
254 | application/timestamped-data tsd
255 | # application/tve-trigger
256 | # application/ulpfec
257 | # application/vcard+xml
258 | # application/vemmi
259 | # application/vividence.scriptfile
260 | # application/vnd.3gpp.bsf+xml
261 | application/vnd.3gpp.pic-bw-large plb
262 | application/vnd.3gpp.pic-bw-small psb
263 | application/vnd.3gpp.pic-bw-var pvb
264 | # application/vnd.3gpp.sms
265 | # application/vnd.3gpp2.bcmcsinfo+xml
266 | # application/vnd.3gpp2.sms
267 | application/vnd.3gpp2.tcap tcap
268 | application/vnd.3m.post-it-notes pwn
269 | application/vnd.accpac.simply.aso aso
270 | application/vnd.accpac.simply.imp imp
271 | application/vnd.acucobol acu
272 | application/vnd.acucorp atc acutc
273 | application/vnd.adobe.air-application-installer-package+zip air
274 | application/vnd.adobe.formscentral.fcdt fcdt
275 | application/vnd.adobe.fxp fxp fxpl
276 | # application/vnd.adobe.partial-upload
277 | application/vnd.adobe.xdp+xml xdp
278 | application/vnd.adobe.xfdf xfdf
279 | # application/vnd.aether.imp
280 | # application/vnd.ah-barcode
281 | application/vnd.ahead.space ahead
282 | application/vnd.airzip.filesecure.azf azf
283 | application/vnd.airzip.filesecure.azs azs
284 | application/vnd.amazon.ebook azw
285 | application/vnd.americandynamics.acc acc
286 | application/vnd.amiga.ami ami
287 | # application/vnd.amundsen.maze+xml
288 | application/vnd.android.package-archive apk
289 | application/vnd.anser-web-certificate-issue-initiation cii
290 | application/vnd.anser-web-funds-transfer-initiation fti
291 | application/vnd.antix.game-component atx
292 | application/vnd.apple.installer+xml mpkg
293 | application/vnd.apple.mpegurl m3u8
294 | # application/vnd.arastra.swi
295 | application/vnd.aristanetworks.swi swi
296 | application/vnd.astraea-software.iota iota
297 | application/vnd.audiograph aep
298 | # application/vnd.autopackage
299 | # application/vnd.avistar+xml
300 | application/vnd.blueice.multipass mpm
301 | # application/vnd.bluetooth.ep.oob
302 | application/vnd.bmi bmi
303 | application/vnd.businessobjects rep
304 | # application/vnd.cab-jscript
305 | # application/vnd.canon-cpdl
306 | # application/vnd.canon-lips
307 | # application/vnd.cendio.thinlinc.clientconf
308 | application/vnd.chemdraw+xml cdxml
309 | application/vnd.chipnuts.karaoke-mmd mmd
310 | application/vnd.cinderella cdy
311 | # application/vnd.cirpack.isdn-ext
312 | application/vnd.claymore cla
313 | application/vnd.cloanto.rp9 rp9
314 | application/vnd.clonk.c4group c4g c4d c4f c4p c4u
315 | application/vnd.cluetrust.cartomobile-config c11amc
316 | application/vnd.cluetrust.cartomobile-config-pkg c11amz
317 | # application/vnd.collection+json
318 | # application/vnd.commerce-battelle
319 | application/vnd.commonspace csp
320 | application/vnd.contact.cmsg cdbcmsg
321 | application/vnd.cosmocaller cmc
322 | application/vnd.crick.clicker clkx
323 | application/vnd.crick.clicker.keyboard clkk
324 | application/vnd.crick.clicker.palette clkp
325 | application/vnd.crick.clicker.template clkt
326 | application/vnd.crick.clicker.wordbank clkw
327 | application/vnd.criticaltools.wbs+xml wbs
328 | application/vnd.ctc-posml pml
329 | # application/vnd.ctct.ws+xml
330 | # application/vnd.cups-pdf
331 | # application/vnd.cups-postscript
332 | application/vnd.cups-ppd ppd
333 | # application/vnd.cups-raster
334 | # application/vnd.cups-raw
335 | # application/vnd.curl
336 | application/vnd.curl.car car
337 | application/vnd.curl.pcurl pcurl
338 | # application/vnd.cybank
339 | application/vnd.dart dart
340 | application/vnd.data-vision.rdz rdz
341 | application/vnd.dece.data uvf uvvf uvd uvvd
342 | application/vnd.dece.ttml+xml uvt uvvt
343 | application/vnd.dece.unspecified uvx uvvx
344 | application/vnd.dece.zip uvz uvvz
345 | application/vnd.denovo.fcselayout-link fe_launch
346 | # application/vnd.dir-bi.plate-dl-nosuffix
347 | application/vnd.dna dna
348 | application/vnd.dolby.mlp mlp
349 | # application/vnd.dolby.mobile.1
350 | # application/vnd.dolby.mobile.2
351 | application/vnd.dpgraph dpg
352 | application/vnd.dreamfactory dfac
353 | application/vnd.ds-keypoint kpxx
354 | application/vnd.dvb.ait ait
355 | # application/vnd.dvb.dvbj
356 | # application/vnd.dvb.esgcontainer
357 | # application/vnd.dvb.ipdcdftnotifaccess
358 | # application/vnd.dvb.ipdcesgaccess
359 | # application/vnd.dvb.ipdcesgaccess2
360 | # application/vnd.dvb.ipdcesgpdd
361 | # application/vnd.dvb.ipdcroaming
362 | # application/vnd.dvb.iptv.alfec-base
363 | # application/vnd.dvb.iptv.alfec-enhancement
364 | # application/vnd.dvb.notif-aggregate-root+xml
365 | # application/vnd.dvb.notif-container+xml
366 | # application/vnd.dvb.notif-generic+xml
367 | # application/vnd.dvb.notif-ia-msglist+xml
368 | # application/vnd.dvb.notif-ia-registration-request+xml
369 | # application/vnd.dvb.notif-ia-registration-response+xml
370 | # application/vnd.dvb.notif-init+xml
371 | # application/vnd.dvb.pfr
372 | application/vnd.dvb.service svc
373 | # application/vnd.dxr
374 | application/vnd.dynageo geo
375 | # application/vnd.easykaraoke.cdgdownload
376 | # application/vnd.ecdis-update
377 | application/vnd.ecowin.chart mag
378 | # application/vnd.ecowin.filerequest
379 | # application/vnd.ecowin.fileupdate
380 | # application/vnd.ecowin.series
381 | # application/vnd.ecowin.seriesrequest
382 | # application/vnd.ecowin.seriesupdate
383 | # application/vnd.emclient.accessrequest+xml
384 | application/vnd.enliven nml
385 | # application/vnd.eprints.data+xml
386 | application/vnd.epson.esf esf
387 | application/vnd.epson.msf msf
388 | application/vnd.epson.quickanime qam
389 | application/vnd.epson.salt slt
390 | application/vnd.epson.ssf ssf
391 | # application/vnd.ericsson.quickcall
392 | application/vnd.eszigno3+xml es3 et3
393 | # application/vnd.etsi.aoc+xml
394 | # application/vnd.etsi.cug+xml
395 | # application/vnd.etsi.iptvcommand+xml
396 | # application/vnd.etsi.iptvdiscovery+xml
397 | # application/vnd.etsi.iptvprofile+xml
398 | # application/vnd.etsi.iptvsad-bc+xml
399 | # application/vnd.etsi.iptvsad-cod+xml
400 | # application/vnd.etsi.iptvsad-npvr+xml
401 | # application/vnd.etsi.iptvservice+xml
402 | # application/vnd.etsi.iptvsync+xml
403 | # application/vnd.etsi.iptvueprofile+xml
404 | # application/vnd.etsi.mcid+xml
405 | # application/vnd.etsi.overload-control-policy-dataset+xml
406 | # application/vnd.etsi.sci+xml
407 | # application/vnd.etsi.simservs+xml
408 | # application/vnd.etsi.tsl+xml
409 | # application/vnd.etsi.tsl.der
410 | # application/vnd.eudora.data
411 | application/vnd.ezpix-album ez2
412 | application/vnd.ezpix-package ez3
413 | # application/vnd.f-secure.mobile
414 | application/vnd.fdf fdf
415 | application/vnd.fdsn.mseed mseed
416 | application/vnd.fdsn.seed seed dataless
417 | # application/vnd.ffsns
418 | # application/vnd.fints
419 | application/vnd.flographit gph
420 | application/vnd.fluxtime.clip ftc
421 | # application/vnd.font-fontforge-sfd
422 | application/vnd.framemaker fm frame maker book
423 | application/vnd.frogans.fnc fnc
424 | application/vnd.frogans.ltf ltf
425 | application/vnd.fsc.weblaunch fsc
426 | application/vnd.fujitsu.oasys oas
427 | application/vnd.fujitsu.oasys2 oa2
428 | application/vnd.fujitsu.oasys3 oa3
429 | application/vnd.fujitsu.oasysgp fg5
430 | application/vnd.fujitsu.oasysprs bh2
431 | # application/vnd.fujixerox.art-ex
432 | # application/vnd.fujixerox.art4
433 | # application/vnd.fujixerox.hbpl
434 | application/vnd.fujixerox.ddd ddd
435 | application/vnd.fujixerox.docuworks xdw
436 | application/vnd.fujixerox.docuworks.binder xbd
437 | # application/vnd.fut-misnet
438 | application/vnd.fuzzysheet fzs
439 | application/vnd.genomatix.tuxedo txd
440 | # application/vnd.geocube+xml
441 | application/vnd.geogebra.file ggb
442 | application/vnd.geogebra.tool ggt
443 | application/vnd.geometry-explorer gex gre
444 | application/vnd.geonext gxt
445 | application/vnd.geoplan g2w
446 | application/vnd.geospace g3w
447 | # application/vnd.globalplatform.card-content-mgt
448 | # application/vnd.globalplatform.card-content-mgt-response
449 | application/vnd.gmx gmx
450 | application/vnd.google-earth.kml+xml kml
451 | application/vnd.google-earth.kmz kmz
452 | application/vnd.grafeq gqf gqs
453 | # application/vnd.gridmp
454 | application/vnd.groove-account gac
455 | application/vnd.groove-help ghf
456 | application/vnd.groove-identity-message gim
457 | application/vnd.groove-injector grv
458 | application/vnd.groove-tool-message gtm
459 | application/vnd.groove-tool-template tpl
460 | application/vnd.groove-vcard vcg
461 | # application/vnd.hal+json
462 | application/vnd.hal+xml hal
463 | application/vnd.handheld-entertainment+xml zmm
464 | application/vnd.hbci hbci
465 | # application/vnd.hcl-bireports
466 | application/vnd.hhe.lesson-player les
467 | application/vnd.hp-hpgl hpgl
468 | application/vnd.hp-hpid hpid
469 | application/vnd.hp-hps hps
470 | application/vnd.hp-jlyt jlt
471 | application/vnd.hp-pcl pcl
472 | application/vnd.hp-pclxl pclxl
473 | # application/vnd.httphone
474 | application/vnd.hydrostatix.sof-data sfd-hdstx
475 | # application/vnd.hzn-3d-crossword
476 | # application/vnd.ibm.afplinedata
477 | # application/vnd.ibm.electronic-media
478 | application/vnd.ibm.minipay mpy
479 | application/vnd.ibm.modcap afp listafp list3820
480 | application/vnd.ibm.rights-management irm
481 | application/vnd.ibm.secure-container sc
482 | application/vnd.iccprofile icc icm
483 | application/vnd.igloader igl
484 | application/vnd.immervision-ivp ivp
485 | application/vnd.immervision-ivu ivu
486 | # application/vnd.informedcontrol.rms+xml
487 | # application/vnd.informix-visionary
488 | # application/vnd.infotech.project
489 | # application/vnd.infotech.project+xml
490 | # application/vnd.innopath.wamp.notification
491 | application/vnd.insors.igm igm
492 | application/vnd.intercon.formnet xpw xpx
493 | application/vnd.intergeo i2g
494 | # application/vnd.intertrust.digibox
495 | # application/vnd.intertrust.nncp
496 | application/vnd.intu.qbo qbo
497 | application/vnd.intu.qfx qfx
498 | # application/vnd.iptc.g2.conceptitem+xml
499 | # application/vnd.iptc.g2.knowledgeitem+xml
500 | # application/vnd.iptc.g2.newsitem+xml
501 | # application/vnd.iptc.g2.newsmessage+xml
502 | # application/vnd.iptc.g2.packageitem+xml
503 | # application/vnd.iptc.g2.planningitem+xml
504 | application/vnd.ipunplugged.rcprofile rcprofile
505 | application/vnd.irepository.package+xml irp
506 | application/vnd.is-xpr xpr
507 | application/vnd.isac.fcs fcs
508 | application/vnd.jam jam
509 | # application/vnd.japannet-directory-service
510 | # application/vnd.japannet-jpnstore-wakeup
511 | # application/vnd.japannet-payment-wakeup
512 | # application/vnd.japannet-registration
513 | # application/vnd.japannet-registration-wakeup
514 | # application/vnd.japannet-setstore-wakeup
515 | # application/vnd.japannet-verification
516 | # application/vnd.japannet-verification-wakeup
517 | application/vnd.jcp.javame.midlet-rms rms
518 | application/vnd.jisp jisp
519 | application/vnd.joost.joda-archive joda
520 | application/vnd.kahootz ktz ktr
521 | application/vnd.kde.karbon karbon
522 | application/vnd.kde.kchart chrt
523 | application/vnd.kde.kformula kfo
524 | application/vnd.kde.kivio flw
525 | application/vnd.kde.kontour kon
526 | application/vnd.kde.kpresenter kpr kpt
527 | application/vnd.kde.kspread ksp
528 | application/vnd.kde.kword kwd kwt
529 | application/vnd.kenameaapp htke
530 | application/vnd.kidspiration kia
531 | application/vnd.kinar kne knp
532 | application/vnd.koan skp skd skt skm
533 | application/vnd.kodak-descriptor sse
534 | application/vnd.las.las+xml lasxml
535 | # application/vnd.liberty-request+xml
536 | application/vnd.llamagraphics.life-balance.desktop lbd
537 | application/vnd.llamagraphics.life-balance.exchange+xml lbe
538 | application/vnd.lotus-1-2-3 123
539 | application/vnd.lotus-approach apr
540 | application/vnd.lotus-freelance pre
541 | application/vnd.lotus-notes nsf
542 | application/vnd.lotus-organizer org
543 | application/vnd.lotus-screencam scm
544 | application/vnd.lotus-wordpro lwp
545 | application/vnd.macports.portpkg portpkg
546 | # application/vnd.marlin.drm.actiontoken+xml
547 | # application/vnd.marlin.drm.conftoken+xml
548 | # application/vnd.marlin.drm.license+xml
549 | # application/vnd.marlin.drm.mdcf
550 | application/vnd.mcd mcd
551 | application/vnd.medcalcdata mc1
552 | application/vnd.mediastation.cdkey cdkey
553 | # application/vnd.meridian-slingshot
554 | application/vnd.mfer mwf
555 | application/vnd.mfmp mfm
556 | application/vnd.micrografx.flo flo
557 | application/vnd.micrografx.igx igx
558 | application/vnd.mif mif
559 | # application/vnd.minisoft-hp3000-save
560 | # application/vnd.mitsubishi.misty-guard.trustweb
561 | application/vnd.mobius.daf daf
562 | application/vnd.mobius.dis dis
563 | application/vnd.mobius.mbk mbk
564 | application/vnd.mobius.mqy mqy
565 | application/vnd.mobius.msl msl
566 | application/vnd.mobius.plc plc
567 | application/vnd.mobius.txf txf
568 | application/vnd.mophun.application mpn
569 | application/vnd.mophun.certificate mpc
570 | # application/vnd.motorola.flexsuite
571 | # application/vnd.motorola.flexsuite.adsi
572 | # application/vnd.motorola.flexsuite.fis
573 | # application/vnd.motorola.flexsuite.gotap
574 | # application/vnd.motorola.flexsuite.kmr
575 | # application/vnd.motorola.flexsuite.ttc
576 | # application/vnd.motorola.flexsuite.wem
577 | # application/vnd.motorola.iprm
578 | application/vnd.mozilla.xul+xml xul
579 | application/vnd.ms-artgalry cil
580 | # application/vnd.ms-asf
581 | application/vnd.ms-cab-compressed cab
582 | # application/vnd.ms-color.iccprofile
583 | application/vnd.ms-excel xls xlm xla xlc xlt xlw
584 | application/vnd.ms-excel.addin.macroenabled.12 xlam
585 | application/vnd.ms-excel.sheet.binary.macroenabled.12 xlsb
586 | application/vnd.ms-excel.sheet.macroenabled.12 xlsm
587 | application/vnd.ms-excel.template.macroenabled.12 xltm
588 | application/vnd.ms-fontobject eot
589 | application/vnd.ms-htmlhelp chm
590 | application/vnd.ms-ims ims
591 | application/vnd.ms-lrm lrm
592 | # application/vnd.ms-office.activex+xml
593 | application/vnd.ms-officetheme thmx
594 | # application/vnd.ms-opentype
595 | # application/vnd.ms-package.obfuscated-opentype
596 | application/vnd.ms-pki.seccat cat
597 | application/vnd.ms-pki.stl stl
598 | # application/vnd.ms-playready.initiator+xml
599 | application/vnd.ms-powerpoint ppt pps pot
600 | application/vnd.ms-powerpoint.addin.macroenabled.12 ppam
601 | application/vnd.ms-powerpoint.presentation.macroenabled.12 pptm
602 | application/vnd.ms-powerpoint.slide.macroenabled.12 sldm
603 | application/vnd.ms-powerpoint.slideshow.macroenabled.12 ppsm
604 | application/vnd.ms-powerpoint.template.macroenabled.12 potm
605 | # application/vnd.ms-printing.printticket+xml
606 | application/vnd.ms-project mpp mpt
607 | # application/vnd.ms-tnef
608 | # application/vnd.ms-wmdrm.lic-chlg-req
609 | # application/vnd.ms-wmdrm.lic-resp
610 | # application/vnd.ms-wmdrm.meter-chlg-req
611 | # application/vnd.ms-wmdrm.meter-resp
612 | application/vnd.ms-word.document.macroenabled.12 docm
613 | application/vnd.ms-word.template.macroenabled.12 dotm
614 | application/vnd.ms-works wps wks wcm wdb
615 | application/vnd.ms-wpl wpl
616 | application/vnd.ms-xpsdocument xps
617 | application/vnd.mseq mseq
618 | # application/vnd.msign
619 | # application/vnd.multiad.creator
620 | # application/vnd.multiad.creator.cif
621 | # application/vnd.music-niff
622 | application/vnd.musician mus
623 | application/vnd.muvee.style msty
624 | application/vnd.mynfc taglet
625 | # application/vnd.ncd.control
626 | # application/vnd.ncd.reference
627 | # application/vnd.nervana
628 | # application/vnd.netfpx
629 | application/vnd.neurolanguage.nlu nlu
630 | application/vnd.nitf ntf nitf
631 | application/vnd.noblenet-directory nnd
632 | application/vnd.noblenet-sealer nns
633 | application/vnd.noblenet-web nnw
634 | # application/vnd.nokia.catalogs
635 | # application/vnd.nokia.conml+wbxml
636 | # application/vnd.nokia.conml+xml
637 | # application/vnd.nokia.isds-radio-presets
638 | # application/vnd.nokia.iptv.config+xml
639 | # application/vnd.nokia.landmark+wbxml
640 | # application/vnd.nokia.landmark+xml
641 | # application/vnd.nokia.landmarkcollection+xml
642 | # application/vnd.nokia.n-gage.ac+xml
643 | application/vnd.nokia.n-gage.data ngdat
644 | application/vnd.nokia.n-gage.symbian.install n-gage
645 | # application/vnd.nokia.ncd
646 | # application/vnd.nokia.pcd+wbxml
647 | # application/vnd.nokia.pcd+xml
648 | application/vnd.nokia.radio-preset rpst
649 | application/vnd.nokia.radio-presets rpss
650 | application/vnd.novadigm.edm edm
651 | application/vnd.novadigm.edx edx
652 | application/vnd.novadigm.ext ext
653 | # application/vnd.ntt-local.file-transfer
654 | # application/vnd.ntt-local.sip-ta_remote
655 | # application/vnd.ntt-local.sip-ta_tcp_stream
656 | application/vnd.oasis.opendocument.chart odc
657 | application/vnd.oasis.opendocument.chart-template otc
658 | application/vnd.oasis.opendocument.database odb
659 | application/vnd.oasis.opendocument.formula odf
660 | application/vnd.oasis.opendocument.formula-template odft
661 | application/vnd.oasis.opendocument.graphics odg
662 | application/vnd.oasis.opendocument.graphics-template otg
663 | application/vnd.oasis.opendocument.image odi
664 | application/vnd.oasis.opendocument.image-template oti
665 | application/vnd.oasis.opendocument.presentation odp
666 | application/vnd.oasis.opendocument.presentation-template otp
667 | application/vnd.oasis.opendocument.spreadsheet ods
668 | application/vnd.oasis.opendocument.spreadsheet-template ots
669 | application/vnd.oasis.opendocument.text odt
670 | application/vnd.oasis.opendocument.text-master odm
671 | application/vnd.oasis.opendocument.text-template ott
672 | application/vnd.oasis.opendocument.text-web oth
673 | # application/vnd.obn
674 | # application/vnd.oftn.l10n+json
675 | # application/vnd.oipf.contentaccessdownload+xml
676 | # application/vnd.oipf.contentaccessstreaming+xml
677 | # application/vnd.oipf.cspg-hexbinary
678 | # application/vnd.oipf.dae.svg+xml
679 | # application/vnd.oipf.dae.xhtml+xml
680 | # application/vnd.oipf.mippvcontrolmessage+xml
681 | # application/vnd.oipf.pae.gem
682 | # application/vnd.oipf.spdiscovery+xml
683 | # application/vnd.oipf.spdlist+xml
684 | # application/vnd.oipf.ueprofile+xml
685 | # application/vnd.oipf.userprofile+xml
686 | application/vnd.olpc-sugar xo
687 | # application/vnd.oma-scws-config
688 | # application/vnd.oma-scws-http-request
689 | # application/vnd.oma-scws-http-response
690 | # application/vnd.oma.bcast.associated-procedure-parameter+xml
691 | # application/vnd.oma.bcast.drm-trigger+xml
692 | # application/vnd.oma.bcast.imd+xml
693 | # application/vnd.oma.bcast.ltkm
694 | # application/vnd.oma.bcast.notification+xml
695 | # application/vnd.oma.bcast.provisioningtrigger
696 | # application/vnd.oma.bcast.sgboot
697 | # application/vnd.oma.bcast.sgdd+xml
698 | # application/vnd.oma.bcast.sgdu
699 | # application/vnd.oma.bcast.simple-symbol-container
700 | # application/vnd.oma.bcast.smartcard-trigger+xml
701 | # application/vnd.oma.bcast.sprov+xml
702 | # application/vnd.oma.bcast.stkm
703 | # application/vnd.oma.cab-address-book+xml
704 | # application/vnd.oma.cab-feature-handler+xml
705 | # application/vnd.oma.cab-pcc+xml
706 | # application/vnd.oma.cab-user-prefs+xml
707 | # application/vnd.oma.dcd
708 | # application/vnd.oma.dcdc
709 | application/vnd.oma.dd2+xml dd2
710 | # application/vnd.oma.drm.risd+xml
711 | # application/vnd.oma.group-usage-list+xml
712 | # application/vnd.oma.pal+xml
713 | # application/vnd.oma.poc.detailed-progress-report+xml
714 | # application/vnd.oma.poc.final-report+xml
715 | # application/vnd.oma.poc.groups+xml
716 | # application/vnd.oma.poc.invocation-descriptor+xml
717 | # application/vnd.oma.poc.optimized-progress-report+xml
718 | # application/vnd.oma.push
719 | # application/vnd.oma.scidm.messages+xml
720 | # application/vnd.oma.xcap-directory+xml
721 | # application/vnd.omads-email+xml
722 | # application/vnd.omads-file+xml
723 | # application/vnd.omads-folder+xml
724 | # application/vnd.omaloc-supl-init
725 | application/vnd.openofficeorg.extension oxt
726 | # application/vnd.openxmlformats-officedocument.custom-properties+xml
727 | # application/vnd.openxmlformats-officedocument.customxmlproperties+xml
728 | # application/vnd.openxmlformats-officedocument.drawing+xml
729 | # application/vnd.openxmlformats-officedocument.drawingml.chart+xml
730 | # application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml
731 | # application/vnd.openxmlformats-officedocument.drawingml.diagramcolors+xml
732 | # application/vnd.openxmlformats-officedocument.drawingml.diagramdata+xml
733 | # application/vnd.openxmlformats-officedocument.drawingml.diagramlayout+xml
734 | # application/vnd.openxmlformats-officedocument.drawingml.diagramstyle+xml
735 | # application/vnd.openxmlformats-officedocument.extended-properties+xml
736 | # application/vnd.openxmlformats-officedocument.presentationml.commentauthors+xml
737 | # application/vnd.openxmlformats-officedocument.presentationml.comments+xml
738 | # application/vnd.openxmlformats-officedocument.presentationml.handoutmaster+xml
739 | # application/vnd.openxmlformats-officedocument.presentationml.notesmaster+xml
740 | # application/vnd.openxmlformats-officedocument.presentationml.notesslide+xml
741 | application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
742 | # application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml
743 | # application/vnd.openxmlformats-officedocument.presentationml.presprops+xml
744 | application/vnd.openxmlformats-officedocument.presentationml.slide sldx
745 | # application/vnd.openxmlformats-officedocument.presentationml.slide+xml
746 | # application/vnd.openxmlformats-officedocument.presentationml.slidelayout+xml
747 | # application/vnd.openxmlformats-officedocument.presentationml.slidemaster+xml
748 | application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx
749 | # application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml
750 | # application/vnd.openxmlformats-officedocument.presentationml.slideupdateinfo+xml
751 | # application/vnd.openxmlformats-officedocument.presentationml.tablestyles+xml
752 | # application/vnd.openxmlformats-officedocument.presentationml.tags+xml
753 | application/vnd.openxmlformats-officedocument.presentationml.template potx
754 | # application/vnd.openxmlformats-officedocument.presentationml.template.main+xml
755 | # application/vnd.openxmlformats-officedocument.presentationml.viewprops+xml
756 | # application/vnd.openxmlformats-officedocument.spreadsheetml.calcchain+xml
757 | # application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml
758 | # application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml
759 | # application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml
760 | # application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml
761 | # application/vnd.openxmlformats-officedocument.spreadsheetml.externallink+xml
762 | # application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcachedefinition+xml
763 | # application/vnd.openxmlformats-officedocument.spreadsheetml.pivotcacherecords+xml
764 | # application/vnd.openxmlformats-officedocument.spreadsheetml.pivottable+xml
765 | # application/vnd.openxmlformats-officedocument.spreadsheetml.querytable+xml
766 | # application/vnd.openxmlformats-officedocument.spreadsheetml.revisionheaders+xml
767 | # application/vnd.openxmlformats-officedocument.spreadsheetml.revisionlog+xml
768 | # application/vnd.openxmlformats-officedocument.spreadsheetml.sharedstrings+xml
769 | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
770 | # application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml
771 | # application/vnd.openxmlformats-officedocument.spreadsheetml.sheetmetadata+xml
772 | # application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml
773 | # application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml
774 | # application/vnd.openxmlformats-officedocument.spreadsheetml.tablesinglecells+xml
775 | application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx
776 | # application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml
777 | # application/vnd.openxmlformats-officedocument.spreadsheetml.usernames+xml
778 | # application/vnd.openxmlformats-officedocument.spreadsheetml.volatiledependencies+xml
779 | # application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml
780 | # application/vnd.openxmlformats-officedocument.theme+xml
781 | # application/vnd.openxmlformats-officedocument.themeoverride+xml
782 | # application/vnd.openxmlformats-officedocument.vmldrawing
783 | # application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml
784 | application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
785 | # application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml
786 | # application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml
787 | # application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml
788 | # application/vnd.openxmlformats-officedocument.wordprocessingml.fonttable+xml
789 | # application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml
790 | # application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml
791 | # application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml
792 | # application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml
793 | # application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml
794 | application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
795 | # application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml
796 | # application/vnd.openxmlformats-officedocument.wordprocessingml.websettings+xml
797 | # application/vnd.openxmlformats-package.core-properties+xml
798 | # application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml
799 | # application/vnd.openxmlformats-package.relationships+xml
800 | # application/vnd.quobject-quoxdocument
801 | # application/vnd.osa.netdeploy
802 | application/vnd.osgeo.mapguide.package mgp
803 | # application/vnd.osgi.bundle
804 | application/vnd.osgi.dp dp
805 | application/vnd.osgi.subsystem esa
806 | # application/vnd.otps.ct-kip+xml
807 | application/vnd.palm pdb pqa oprc
808 | # application/vnd.paos.xml
809 | application/vnd.pawaafile paw
810 | application/vnd.pg.format str
811 | application/vnd.pg.osasli ei6
812 | # application/vnd.piaccess.application-licence
813 | application/vnd.picsel efif
814 | application/vnd.pmi.widget wg
815 | # application/vnd.poc.group-advertisement+xml
816 | application/vnd.pocketlearn plf
817 | application/vnd.powerbuilder6 pbd
818 | # application/vnd.powerbuilder6-s
819 | # application/vnd.powerbuilder7
820 | # application/vnd.powerbuilder7-s
821 | # application/vnd.powerbuilder75
822 | # application/vnd.powerbuilder75-s
823 | # application/vnd.preminet
824 | application/vnd.previewsystems.box box
825 | application/vnd.proteus.magazine mgz
826 | application/vnd.publishare-delta-tree qps
827 | application/vnd.pvi.ptid1 ptid
828 | # application/vnd.pwg-multiplexed
829 | # application/vnd.pwg-xhtml-print+xml
830 | # application/vnd.qualcomm.brew-app-res
831 | application/vnd.quark.quarkxpress qxd qxt qwd qwt qxl qxb
832 | # application/vnd.radisys.moml+xml
833 | # application/vnd.radisys.msml+xml
834 | # application/vnd.radisys.msml-audit+xml
835 | # application/vnd.radisys.msml-audit-conf+xml
836 | # application/vnd.radisys.msml-audit-conn+xml
837 | # application/vnd.radisys.msml-audit-dialog+xml
838 | # application/vnd.radisys.msml-audit-stream+xml
839 | # application/vnd.radisys.msml-conf+xml
840 | # application/vnd.radisys.msml-dialog+xml
841 | # application/vnd.radisys.msml-dialog-base+xml
842 | # application/vnd.radisys.msml-dialog-fax-detect+xml
843 | # application/vnd.radisys.msml-dialog-fax-sendrecv+xml
844 | # application/vnd.radisys.msml-dialog-group+xml
845 | # application/vnd.radisys.msml-dialog-speech+xml
846 | # application/vnd.radisys.msml-dialog-transform+xml
847 | # application/vnd.rainstor.data
848 | # application/vnd.rapid
849 | application/vnd.realvnc.bed bed
850 | application/vnd.recordare.musicxml mxl
851 | application/vnd.recordare.musicxml+xml musicxml
852 | # application/vnd.renlearn.rlprint
853 | application/vnd.rig.cryptonote cryptonote
854 | application/vnd.rim.cod cod
855 | application/vnd.rn-realmedia rm
856 | application/vnd.rn-realmedia-vbr rmvb
857 | application/vnd.route66.link66+xml link66
858 | # application/vnd.rs-274x
859 | # application/vnd.ruckus.download
860 | # application/vnd.s3sms
861 | application/vnd.sailingtracker.track st
862 | # application/vnd.sbm.cid
863 | # application/vnd.sbm.mid2
864 | # application/vnd.scribus
865 | # application/vnd.sealed.3df
866 | # application/vnd.sealed.csf
867 | # application/vnd.sealed.doc
868 | # application/vnd.sealed.eml
869 | # application/vnd.sealed.mht
870 | # application/vnd.sealed.net
871 | # application/vnd.sealed.ppt
872 | # application/vnd.sealed.tiff
873 | # application/vnd.sealed.xls
874 | # application/vnd.sealedmedia.softseal.html
875 | # application/vnd.sealedmedia.softseal.pdf
876 | application/vnd.seemail see
877 | application/vnd.sema sema
878 | application/vnd.semd semd
879 | application/vnd.semf semf
880 | application/vnd.shana.informed.formdata ifm
881 | application/vnd.shana.informed.formtemplate itp
882 | application/vnd.shana.informed.interchange iif
883 | application/vnd.shana.informed.package ipk
884 | application/vnd.simtech-mindmapper twd twds
885 | application/vnd.smaf mmf
886 | # application/vnd.smart.notebook
887 | application/vnd.smart.teacher teacher
888 | # application/vnd.software602.filler.form+xml
889 | # application/vnd.software602.filler.form-xml-zip
890 | application/vnd.solent.sdkm+xml sdkm sdkd
891 | application/vnd.spotfire.dxp dxp
892 | application/vnd.spotfire.sfs sfs
893 | # application/vnd.sss-cod
894 | # application/vnd.sss-dtf
895 | # application/vnd.sss-ntf
896 | application/vnd.stardivision.calc sdc
897 | application/vnd.stardivision.draw sda
898 | application/vnd.stardivision.impress sdd
899 | application/vnd.stardivision.math smf
900 | application/vnd.stardivision.writer sdw vor
901 | application/vnd.stardivision.writer-global sgl
902 | application/vnd.stepmania.package smzip
903 | application/vnd.stepmania.stepchart sm
904 | # application/vnd.street-stream
905 | application/vnd.sun.xml.calc sxc
906 | application/vnd.sun.xml.calc.template stc
907 | application/vnd.sun.xml.draw sxd
908 | application/vnd.sun.xml.draw.template std
909 | application/vnd.sun.xml.impress sxi
910 | application/vnd.sun.xml.impress.template sti
911 | application/vnd.sun.xml.math sxm
912 | application/vnd.sun.xml.writer sxw
913 | application/vnd.sun.xml.writer.global sxg
914 | application/vnd.sun.xml.writer.template stw
915 | # application/vnd.sun.wadl+xml
916 | application/vnd.sus-calendar sus susp
917 | application/vnd.svd svd
918 | # application/vnd.swiftview-ics
919 | application/vnd.symbian.install sis sisx
920 | application/vnd.syncml+xml xsm
921 | application/vnd.syncml.dm+wbxml bdm
922 | application/vnd.syncml.dm+xml xdm
923 | # application/vnd.syncml.dm.notification
924 | # application/vnd.syncml.ds.notification
925 | application/vnd.tao.intent-module-archive tao
926 | application/vnd.tcpdump.pcap pcap cap dmp
927 | application/vnd.tmobile-livetv tmo
928 | application/vnd.trid.tpt tpt
929 | application/vnd.triscape.mxs mxs
930 | application/vnd.trueapp tra
931 | # application/vnd.truedoc
932 | # application/vnd.ubisoft.webplayer
933 | application/vnd.ufdl ufd ufdl
934 | application/vnd.uiq.theme utz
935 | application/vnd.umajin umj
936 | application/vnd.unity unityweb
937 | application/vnd.uoml+xml uoml
938 | # application/vnd.uplanet.alert
939 | # application/vnd.uplanet.alert-wbxml
940 | # application/vnd.uplanet.bearer-choice
941 | # application/vnd.uplanet.bearer-choice-wbxml
942 | # application/vnd.uplanet.cacheop
943 | # application/vnd.uplanet.cacheop-wbxml
944 | # application/vnd.uplanet.channel
945 | # application/vnd.uplanet.channel-wbxml
946 | # application/vnd.uplanet.list
947 | # application/vnd.uplanet.list-wbxml
948 | # application/vnd.uplanet.listcmd
949 | # application/vnd.uplanet.listcmd-wbxml
950 | # application/vnd.uplanet.signal
951 | application/vnd.vcx vcx
952 | # application/vnd.vd-study
953 | # application/vnd.vectorworks
954 | # application/vnd.verimatrix.vcas
955 | # application/vnd.vidsoft.vidconference
956 | application/vnd.visio vsd vst vss vsw
957 | application/vnd.visionary vis
958 | # application/vnd.vividence.scriptfile
959 | application/vnd.vsf vsf
960 | # application/vnd.wap.sic
961 | # application/vnd.wap.slc
962 | application/vnd.wap.wbxml wbxml
963 | application/vnd.wap.wmlc wmlc
964 | application/vnd.wap.wmlscriptc wmlsc
965 | application/vnd.webturbo wtb
966 | # application/vnd.wfa.wsc
967 | # application/vnd.wmc
968 | # application/vnd.wmf.bootstrap
969 | # application/vnd.wolfram.mathematica
970 | # application/vnd.wolfram.mathematica.package
971 | application/vnd.wolfram.player nbp
972 | application/vnd.wordperfect wpd
973 | application/vnd.wqd wqd
974 | # application/vnd.wrq-hp3000-labelled
975 | application/vnd.wt.stf stf
976 | # application/vnd.wv.csp+wbxml
977 | # application/vnd.wv.csp+xml
978 | # application/vnd.wv.ssp+xml
979 | application/vnd.xara xar
980 | application/vnd.xfdl xfdl
981 | # application/vnd.xfdl.webform
982 | # application/vnd.xmi+xml
983 | # application/vnd.xmpie.cpkg
984 | # application/vnd.xmpie.dpkg
985 | # application/vnd.xmpie.plan
986 | # application/vnd.xmpie.ppkg
987 | # application/vnd.xmpie.xlim
988 | application/vnd.yamaha.hv-dic hvd
989 | application/vnd.yamaha.hv-script hvs
990 | application/vnd.yamaha.hv-voice hvp
991 | application/vnd.yamaha.openscoreformat osf
992 | application/vnd.yamaha.openscoreformat.osfpvg+xml osfpvg
993 | # application/vnd.yamaha.remote-setup
994 | application/vnd.yamaha.smaf-audio saf
995 | application/vnd.yamaha.smaf-phrase spf
996 | # application/vnd.yamaha.through-ngn
997 | # application/vnd.yamaha.tunnel-udpencap
998 | application/vnd.yellowriver-custom-menu cmp
999 | application/vnd.zul zir zirz
1000 | application/vnd.zzazz.deck+xml zaz
1001 | application/voicexml+xml vxml
1002 | # application/vq-rtcpxr
1003 | # application/watcherinfo+xml
1004 | # application/whoispp-query
1005 | # application/whoispp-response
1006 | application/widget wgt
1007 | application/winhlp hlp
1008 | # application/wita
1009 | # application/wordperfect5.1
1010 | application/wsdl+xml wsdl
1011 | application/wspolicy+xml wspolicy
1012 | application/x-7z-compressed 7z
1013 | application/x-abiword abw
1014 | application/x-ace-compressed ace
1015 | # application/x-amf
1016 | application/x-apple-diskimage dmg
1017 | application/x-authorware-bin aab x32 u32 vox
1018 | application/x-authorware-map aam
1019 | application/x-authorware-seg aas
1020 | application/x-bcpio bcpio
1021 | application/x-bittorrent torrent
1022 | application/x-blorb blb blorb
1023 | application/x-bzip bz
1024 | application/x-bzip2 bz2 boz
1025 | application/x-cbr cbr cba cbt cbz cb7
1026 | application/x-cdlink vcd
1027 | application/x-cfs-compressed cfs
1028 | application/x-chat chat
1029 | application/x-chess-pgn pgn
1030 | application/x-conference nsc
1031 | # application/x-compress
1032 | application/x-cpio cpio
1033 | application/x-csh csh
1034 | application/x-debian-package deb udeb
1035 | application/x-dgc-compressed dgc
1036 | application/x-director dir dcr dxr cst cct cxt w3d fgd swa
1037 | application/x-doom wad
1038 | application/x-dtbncx+xml ncx
1039 | application/x-dtbook+xml dtb
1040 | application/x-dtbresource+xml res
1041 | application/x-dvi dvi
1042 | application/x-envoy evy
1043 | application/x-eva eva
1044 | application/x-font-bdf bdf
1045 | # application/x-font-dos
1046 | # application/x-font-framemaker
1047 | application/x-font-ghostscript gsf
1048 | # application/x-font-libgrx
1049 | application/x-font-linux-psf psf
1050 | application/x-font-otf otf
1051 | application/x-font-pcf pcf
1052 | application/x-font-snf snf
1053 | # application/x-font-speedo
1054 | # application/x-font-sunos-news
1055 | application/x-font-ttf ttf ttc
1056 | application/x-font-type1 pfa pfb pfm afm
1057 | application/font-woff woff
1058 | # application/x-font-vfont
1059 | application/x-freearc arc
1060 | application/x-futuresplash spl
1061 | application/x-gca-compressed gca
1062 | application/x-glulx ulx
1063 | application/x-gnumeric gnumeric
1064 | application/x-gramps-xml gramps
1065 | application/x-gtar gtar
1066 | # application/x-gzip
1067 | application/x-hdf hdf
1068 | application/x-install-instructions install
1069 | application/x-iso9660-image iso
1070 | application/x-java-jnlp-file jnlp
1071 | application/x-latex latex
1072 | application/x-lzh-compressed lzh lha
1073 | application/x-mie mie
1074 | application/x-mobipocket-ebook prc mobi
1075 | application/x-ms-application application
1076 | application/x-ms-shortcut lnk
1077 | application/x-ms-wmd wmd
1078 | application/x-ms-wmz wmz
1079 | application/x-ms-xbap xbap
1080 | application/x-msaccess mdb
1081 | application/x-msbinder obd
1082 | application/x-mscardfile crd
1083 | application/x-msclip clp
1084 | application/x-msdownload exe dll com bat msi
1085 | application/x-msmediaview mvb m13 m14
1086 | application/x-msmetafile wmf wmz emf emz
1087 | application/x-msmoney mny
1088 | application/x-mspublisher pub
1089 | application/x-msschedule scd
1090 | application/x-msterminal trm
1091 | application/x-mswrite wri
1092 | application/x-netcdf nc cdf
1093 | application/x-nzb nzb
1094 | application/x-pkcs12 p12 pfx
1095 | application/x-pkcs7-certificates p7b spc
1096 | application/x-pkcs7-certreqresp p7r
1097 | application/x-rar-compressed rar
1098 | application/x-research-info-systems ris
1099 | application/x-sh sh
1100 | application/x-shar shar
1101 | application/x-shockwave-flash swf
1102 | application/x-silverlight-app xap
1103 | application/x-sql sql
1104 | application/x-stuffit sit
1105 | application/x-stuffitx sitx
1106 | application/x-subrip srt
1107 | application/x-sv4cpio sv4cpio
1108 | application/x-sv4crc sv4crc
1109 | application/x-t3vm-image t3
1110 | application/x-tads gam
1111 | application/x-tar tar
1112 | application/x-tcl tcl
1113 | application/x-tex tex
1114 | application/x-tex-tfm tfm
1115 | application/x-texinfo texinfo texi
1116 | application/x-tgif obj
1117 | application/x-ustar ustar
1118 | application/x-wais-source src
1119 | application/x-x509-ca-cert der crt
1120 | application/x-xfig fig
1121 | application/x-xliff+xml xlf
1122 | application/x-xpinstall xpi
1123 | application/x-xz xz
1124 | application/x-zmachine z1 z2 z3 z4 z5 z6 z7 z8
1125 | # application/x400-bp
1126 | application/xaml+xml xaml
1127 | # application/xcap-att+xml
1128 | # application/xcap-caps+xml
1129 | application/xcap-diff+xml xdf
1130 | # application/xcap-el+xml
1131 | # application/xcap-error+xml
1132 | # application/xcap-ns+xml
1133 | # application/xcon-conference-info-diff+xml
1134 | # application/xcon-conference-info+xml
1135 | application/xenc+xml xenc
1136 | application/xhtml+xml xhtml xht
1137 | # application/xhtml-voice+xml
1138 | application/xml xml xsl
1139 | application/xml-dtd dtd
1140 | # application/xml-external-parsed-entity
1141 | # application/xmpp+xml
1142 | application/xop+xml xop
1143 | application/xproc+xml xpl
1144 | application/xslt+xml xslt
1145 | application/xspf+xml xspf
1146 | application/xv+xml mxml xhvml xvml xvm
1147 | application/yang yang
1148 | application/yin+xml yin
1149 | application/zip zip
1150 | # audio/1d-interleaved-parityfec
1151 | # audio/32kadpcm
1152 | # audio/3gpp
1153 | # audio/3gpp2
1154 | # audio/ac3
1155 | audio/adpcm adp
1156 | # audio/amr
1157 | # audio/amr-wb
1158 | # audio/amr-wb+
1159 | # audio/asc
1160 | # audio/atrac-advanced-lossless
1161 | # audio/atrac-x
1162 | # audio/atrac3
1163 | audio/basic au snd
1164 | # audio/bv16
1165 | # audio/bv32
1166 | # audio/clearmode
1167 | # audio/cn
1168 | # audio/dat12
1169 | # audio/dls
1170 | # audio/dsr-es201108
1171 | # audio/dsr-es202050
1172 | # audio/dsr-es202211
1173 | # audio/dsr-es202212
1174 | # audio/dv
1175 | # audio/dvi4
1176 | # audio/eac3
1177 | # audio/evrc
1178 | # audio/evrc-qcp
1179 | # audio/evrc0
1180 | # audio/evrc1
1181 | # audio/evrcb
1182 | # audio/evrcb0
1183 | # audio/evrcb1
1184 | # audio/evrcwb
1185 | # audio/evrcwb0
1186 | # audio/evrcwb1
1187 | # audio/example
1188 | # audio/fwdred
1189 | # audio/g719
1190 | # audio/g722
1191 | # audio/g7221
1192 | # audio/g723
1193 | # audio/g726-16
1194 | # audio/g726-24
1195 | # audio/g726-32
1196 | # audio/g726-40
1197 | # audio/g728
1198 | # audio/g729
1199 | # audio/g7291
1200 | # audio/g729d
1201 | # audio/g729e
1202 | # audio/gsm
1203 | # audio/gsm-efr
1204 | # audio/gsm-hr-08
1205 | # audio/ilbc
1206 | # audio/ip-mr_v2.5
1207 | # audio/isac
1208 | # audio/l16
1209 | # audio/l20
1210 | # audio/l24
1211 | # audio/l8
1212 | # audio/lpc
1213 | audio/midi mid midi kar rmi
1214 | # audio/mobile-xmf
1215 | audio/mp4 mp4a
1216 | # audio/mp4a-latm
1217 | # audio/mpa
1218 | # audio/mpa-robust
1219 | audio/mpeg mpga mp2 mp2a mp3 m2a m3a
1220 | # audio/mpeg4-generic
1221 | # audio/musepack
1222 | audio/ogg oga ogg spx
1223 | # audio/opus
1224 | # audio/parityfec
1225 | # audio/pcma
1226 | # audio/pcma-wb
1227 | # audio/pcmu-wb
1228 | # audio/pcmu
1229 | # audio/prs.sid
1230 | # audio/qcelp
1231 | # audio/red
1232 | # audio/rtp-enc-aescm128
1233 | # audio/rtp-midi
1234 | # audio/rtx
1235 | audio/s3m s3m
1236 | audio/silk sil
1237 | # audio/smv
1238 | # audio/smv0
1239 | # audio/smv-qcp
1240 | # audio/sp-midi
1241 | # audio/speex
1242 | # audio/t140c
1243 | # audio/t38
1244 | # audio/telephone-event
1245 | # audio/tone
1246 | # audio/uemclip
1247 | # audio/ulpfec
1248 | # audio/vdvi
1249 | # audio/vmr-wb
1250 | # audio/vnd.3gpp.iufp
1251 | # audio/vnd.4sb
1252 | # audio/vnd.audiokoz
1253 | # audio/vnd.celp
1254 | # audio/vnd.cisco.nse
1255 | # audio/vnd.cmles.radio-events
1256 | # audio/vnd.cns.anp1
1257 | # audio/vnd.cns.inf1
1258 | audio/vnd.dece.audio uva uvva
1259 | audio/vnd.digital-winds eol
1260 | # audio/vnd.dlna.adts
1261 | # audio/vnd.dolby.heaac.1
1262 | # audio/vnd.dolby.heaac.2
1263 | # audio/vnd.dolby.mlp
1264 | # audio/vnd.dolby.mps
1265 | # audio/vnd.dolby.pl2
1266 | # audio/vnd.dolby.pl2x
1267 | # audio/vnd.dolby.pl2z
1268 | # audio/vnd.dolby.pulse.1
1269 | audio/vnd.dra dra
1270 | audio/vnd.dts dts
1271 | audio/vnd.dts.hd dtshd
1272 | # audio/vnd.dvb.file
1273 | # audio/vnd.everad.plj
1274 | # audio/vnd.hns.audio
1275 | audio/vnd.lucent.voice lvp
1276 | audio/vnd.ms-playready.media.pya pya
1277 | # audio/vnd.nokia.mobile-xmf
1278 | # audio/vnd.nortel.vbk
1279 | audio/vnd.nuera.ecelp4800 ecelp4800
1280 | audio/vnd.nuera.ecelp7470 ecelp7470
1281 | audio/vnd.nuera.ecelp9600 ecelp9600
1282 | # audio/vnd.octel.sbc
1283 | # audio/vnd.qcelp
1284 | # audio/vnd.rhetorex.32kadpcm
1285 | audio/vnd.rip rip
1286 | # audio/vnd.sealedmedia.softseal.mpeg
1287 | # audio/vnd.vmx.cvsd
1288 | # audio/vorbis
1289 | # audio/vorbis-config
1290 | audio/webm weba
1291 | audio/x-aac aac
1292 | audio/x-aiff aif aiff aifc
1293 | audio/x-caf caf
1294 | audio/x-flac flac
1295 | audio/x-matroska mka
1296 | audio/x-mpegurl m3u
1297 | audio/x-ms-wax wax
1298 | audio/x-ms-wma wma
1299 | audio/x-pn-realaudio ram ra
1300 | audio/x-pn-realaudio-plugin rmp
1301 | # audio/x-tta
1302 | audio/x-wav wav
1303 | audio/xm xm
1304 | chemical/x-cdx cdx
1305 | chemical/x-cif cif
1306 | chemical/x-cmdf cmdf
1307 | chemical/x-cml cml
1308 | chemical/x-csml csml
1309 | # chemical/x-pdb
1310 | chemical/x-xyz xyz
1311 | image/bmp bmp
1312 | image/cgm cgm
1313 | # image/example
1314 | # image/fits
1315 | image/g3fax g3
1316 | image/gif gif
1317 | image/ief ief
1318 | # image/jp2
1319 | image/jpeg jpeg jpg jpe
1320 | # image/jpm
1321 | # image/jpx
1322 | image/ktx ktx
1323 | # image/naplps
1324 | image/png png
1325 | image/prs.btif btif
1326 | # image/prs.pti
1327 | image/sgi sgi
1328 | image/svg+xml svg svgz
1329 | # image/t38
1330 | image/tiff tiff tif
1331 | # image/tiff-fx
1332 | image/vnd.adobe.photoshop psd
1333 | # image/vnd.cns.inf2
1334 | image/vnd.dece.graphic uvi uvvi uvg uvvg
1335 | image/vnd.dvb.subtitle sub
1336 | image/vnd.djvu djvu djv
1337 | image/vnd.dwg dwg
1338 | image/vnd.dxf dxf
1339 | image/vnd.fastbidsheet fbs
1340 | image/vnd.fpx fpx
1341 | image/vnd.fst fst
1342 | image/vnd.fujixerox.edmics-mmr mmr
1343 | image/vnd.fujixerox.edmics-rlc rlc
1344 | # image/vnd.globalgraphics.pgb
1345 | # image/vnd.microsoft.icon
1346 | # image/vnd.mix
1347 | image/vnd.ms-modi mdi
1348 | image/vnd.ms-photo wdp
1349 | image/vnd.net-fpx npx
1350 | # image/vnd.radiance
1351 | # image/vnd.sealed.png
1352 | # image/vnd.sealedmedia.softseal.gif
1353 | # image/vnd.sealedmedia.softseal.jpg
1354 | # image/vnd.svf
1355 | image/vnd.wap.wbmp wbmp
1356 | image/vnd.xiff xif
1357 | image/webp webp
1358 | image/x-3ds 3ds
1359 | image/x-cmu-raster ras
1360 | image/x-cmx cmx
1361 | image/x-freehand fh fhc fh4 fh5 fh7
1362 | image/x-icon ico
1363 | image/x-mrsid-image sid
1364 | image/x-pcx pcx
1365 | image/x-pict pic pct
1366 | image/x-portable-anymap pnm
1367 | image/x-portable-bitmap pbm
1368 | image/x-portable-graymap pgm
1369 | image/x-portable-pixmap ppm
1370 | image/x-rgb rgb
1371 | image/x-tga tga
1372 | image/x-xbitmap xbm
1373 | image/x-xpixmap xpm
1374 | image/x-xwindowdump xwd
1375 | # message/cpim
1376 | # message/delivery-status
1377 | # message/disposition-notification
1378 | # message/example
1379 | # message/external-body
1380 | # message/feedback-report
1381 | # message/global
1382 | # message/global-delivery-status
1383 | # message/global-disposition-notification
1384 | # message/global-headers
1385 | # message/http
1386 | # message/imdn+xml
1387 | # message/news
1388 | # message/partial
1389 | message/rfc822 eml mime
1390 | # message/s-http
1391 | # message/sip
1392 | # message/sipfrag
1393 | # message/tracking-status
1394 | # message/vnd.si.simp
1395 | # model/example
1396 | model/iges igs iges
1397 | model/mesh msh mesh silo
1398 | model/vnd.collada+xml dae
1399 | model/vnd.dwf dwf
1400 | # model/vnd.flatland.3dml
1401 | model/vnd.gdl gdl
1402 | # model/vnd.gs-gdl
1403 | # model/vnd.gs.gdl
1404 | model/vnd.gtw gtw
1405 | # model/vnd.moml+xml
1406 | model/vnd.mts mts
1407 | # model/vnd.parasolid.transmit.binary
1408 | # model/vnd.parasolid.transmit.text
1409 | model/vnd.vtu vtu
1410 | model/vrml wrl vrml
1411 | model/x3d+binary x3db x3dbz
1412 | model/x3d+vrml x3dv x3dvz
1413 | model/x3d+xml x3d x3dz
1414 | # multipart/alternative
1415 | # multipart/appledouble
1416 | # multipart/byteranges
1417 | # multipart/digest
1418 | # multipart/encrypted
1419 | # multipart/example
1420 | # multipart/form-data
1421 | # multipart/header-set
1422 | # multipart/mixed
1423 | # multipart/parallel
1424 | # multipart/related
1425 | # multipart/report
1426 | # multipart/signed
1427 | # multipart/voice-message
1428 | # text/1d-interleaved-parityfec
1429 | text/cache-manifest appcache
1430 | text/calendar ics ifb
1431 | text/css css
1432 | text/csv csv
1433 | # text/directory
1434 | # text/dns
1435 | # text/ecmascript
1436 | # text/enriched
1437 | # text/example
1438 | # text/fwdred
1439 | text/html html htm
1440 | # text/javascript
1441 | text/n3 n3
1442 | # text/parityfec
1443 | text/plain txt text conf def list log in
1444 | # text/prs.fallenstein.rst
1445 | text/prs.lines.tag dsc
1446 | # text/vnd.radisys.msml-basic-layout
1447 | # text/red
1448 | # text/rfc822-headers
1449 | text/richtext rtx
1450 | # text/rtf
1451 | # text/rtp-enc-aescm128
1452 | # text/rtx
1453 | text/sgml sgml sgm
1454 | # text/t140
1455 | text/tab-separated-values tsv
1456 | text/troff t tr roff man me ms
1457 | text/turtle ttl
1458 | # text/ulpfec
1459 | text/uri-list uri uris urls
1460 | text/vcard vcard
1461 | # text/vnd.abc
1462 | text/vnd.curl curl
1463 | text/vnd.curl.dcurl dcurl
1464 | text/vnd.curl.scurl scurl
1465 | text/vnd.curl.mcurl mcurl
1466 | # text/vnd.dmclientscript
1467 | text/vnd.dvb.subtitle sub
1468 | # text/vnd.esmertec.theme-descriptor
1469 | text/vnd.fly fly
1470 | text/vnd.fmi.flexstor flx
1471 | text/vnd.graphviz gv
1472 | text/vnd.in3d.3dml 3dml
1473 | text/vnd.in3d.spot spot
1474 | # text/vnd.iptc.newsml
1475 | # text/vnd.iptc.nitf
1476 | # text/vnd.latex-z
1477 | # text/vnd.motorola.reflex
1478 | # text/vnd.ms-mediapackage
1479 | # text/vnd.net2phone.commcenter.command
1480 | # text/vnd.si.uricatalogue
1481 | text/vnd.sun.j2me.app-descriptor jad
1482 | # text/vnd.trolltech.linguist
1483 | # text/vnd.wap.si
1484 | # text/vnd.wap.sl
1485 | text/vnd.wap.wml wml
1486 | text/vnd.wap.wmlscript wmls
1487 | text/x-asm s asm
1488 | text/x-c c cc cxx cpp h hh dic
1489 | text/x-fortran f for f77 f90
1490 | text/x-java-source java
1491 | text/x-opml opml
1492 | text/x-pascal p pas
1493 | text/x-nfo nfo
1494 | text/x-setext etx
1495 | text/x-sfv sfv
1496 | text/x-uuencode uu
1497 | text/x-vcalendar vcs
1498 | text/x-vcard vcf
1499 | # text/xml
1500 | # text/xml-external-parsed-entity
1501 | # video/1d-interleaved-parityfec
1502 | video/3gpp 3gp
1503 | # video/3gpp-tt
1504 | video/3gpp2 3g2
1505 | # video/bmpeg
1506 | # video/bt656
1507 | # video/celb
1508 | # video/dv
1509 | # video/example
1510 | video/h261 h261
1511 | video/h263 h263
1512 | # video/h263-1998
1513 | # video/h263-2000
1514 | video/h264 h264
1515 | # video/h264-rcdo
1516 | # video/h264-svc
1517 | video/jpeg jpgv
1518 | # video/jpeg2000
1519 | video/jpm jpm jpgm
1520 | video/mj2 mj2 mjp2
1521 | # video/mp1s
1522 | # video/mp2p
1523 | # video/mp2t
1524 | video/mp4 mp4 mp4v mpg4
1525 | # video/mp4v-es
1526 | video/mpeg mpeg mpg mpe m1v m2v
1527 | # video/mpeg4-generic
1528 | # video/mpv
1529 | # video/nv
1530 | video/ogg ogv
1531 | # video/parityfec
1532 | # video/pointer
1533 | video/quicktime qt mov
1534 | # video/raw
1535 | # video/rtp-enc-aescm128
1536 | # video/rtx
1537 | # video/smpte292m
1538 | # video/ulpfec
1539 | # video/vc1
1540 | # video/vnd.cctv
1541 | video/vnd.dece.hd uvh uvvh
1542 | video/vnd.dece.mobile uvm uvvm
1543 | # video/vnd.dece.mp4
1544 | video/vnd.dece.pd uvp uvvp
1545 | video/vnd.dece.sd uvs uvvs
1546 | video/vnd.dece.video uvv uvvv
1547 | # video/vnd.directv.mpeg
1548 | # video/vnd.directv.mpeg-tts
1549 | # video/vnd.dlna.mpeg-tts
1550 | video/vnd.dvb.file dvb
1551 | video/vnd.fvt fvt
1552 | # video/vnd.hns.video
1553 | # video/vnd.iptvforum.1dparityfec-1010
1554 | # video/vnd.iptvforum.1dparityfec-2005
1555 | # video/vnd.iptvforum.2dparityfec-1010
1556 | # video/vnd.iptvforum.2dparityfec-2005
1557 | # video/vnd.iptvforum.ttsavc
1558 | # video/vnd.iptvforum.ttsmpeg2
1559 | # video/vnd.motorola.video
1560 | # video/vnd.motorola.videop
1561 | video/vnd.mpegurl mxu m4u
1562 | video/vnd.ms-playready.media.pyv pyv
1563 | # video/vnd.nokia.interleaved-multimedia
1564 | # video/vnd.nokia.videovoip
1565 | # video/vnd.objectvideo
1566 | # video/vnd.sealed.mpeg1
1567 | # video/vnd.sealed.mpeg4
1568 | # video/vnd.sealed.swf
1569 | # video/vnd.sealedmedia.softseal.mov
1570 | video/vnd.uvvu.mp4 uvu uvvu
1571 | video/vnd.vivo viv
1572 | video/webm webm
1573 | video/x-f4v f4v
1574 | video/x-fli fli
1575 | video/x-flv flv
1576 | video/x-m4v m4v
1577 | video/x-matroska mkv mk3d mks
1578 | video/x-mng mng
1579 | video/x-ms-asf asf asx
1580 | video/x-ms-vob vob
1581 | video/x-ms-wm wm
1582 | video/x-ms-wmv wmv
1583 | video/x-ms-wmx wmx
1584 | video/x-ms-wvx wvx
1585 | video/x-msvideo avi
1586 | video/x-sgi-movie movie
1587 | video/x-smv smv
1588 | x-conference/x-cooltalk ice
1589 |
--------------------------------------------------------------------------------
/plugs/mime/types/node.types:
--------------------------------------------------------------------------------
1 | # What: WebVTT
2 | # Why: To allow formats intended for marking up external text track resources.
3 | # http://dev.w3.org/html5/webvtt/
4 | # Added by: niftylettuce
5 | text/vtt vtt
6 |
7 | # What: Google Chrome Extension
8 | # Why: To allow apps to (work) be served with the right content type header.
9 | # http://codereview.chromium.org/2830017
10 | # Added by: niftylettuce
11 | application/x-chrome-extension crx
12 |
13 | # What: HTC support
14 | # Why: To properly render .htc files such as CSS3PIE
15 | # Added by: niftylettuce
16 | text/x-component htc
17 |
18 | # What: HTML5 application cache manifes ('.manifest' extension)
19 | # Why: De-facto standard. Required by Mozilla browser when serving HTML5 apps
20 | # per https://developer.mozilla.org/en/offline_resources_in_firefox
21 | # Added by: louisremi
22 | text/cache-manifest manifest
23 |
24 | # What: node binary buffer format
25 | # Why: semi-standard extension w/in the node community
26 | # Added by: tootallnate
27 | application/octet-stream buffer
28 |
29 | # What: The "protected" MP-4 formats used by iTunes.
30 | # Why: Required for streaming music to browsers (?)
31 | # Added by: broofa
32 | application/mp4 m4p
33 | audio/mp4 m4a
34 |
35 | # What: Video format, Part of RFC1890
36 | # Why: See https://github.com/bentomas/node-mime/pull/6
37 | # Added by: mjrusso
38 | video/MP2T ts
39 |
40 | # What: EventSource mime type
41 | # Why: mime type of Server-Sent Events stream
42 | # http://www.w3.org/TR/eventsource/#text-event-stream
43 | # Added by: francois2metz
44 | text/event-stream event-stream
45 |
46 | # What: Mozilla App manifest mime type
47 | # Why: https://developer.mozilla.org/en/Apps/Manifest#Serving_manifests
48 | # Added by: ednapiranha
49 | application/x-web-app-manifest+json webapp
50 |
51 | # What: Lua file types
52 | # Why: Googling around shows de-facto consensus on these
53 | # Added by: creationix (Issue #45)
54 | text/x-lua lua
55 | application/x-lua-bytecode luac
56 |
57 | # What: Markdown files, as per http://daringfireball.net/projects/markdown/syntax
58 | # Why: http://stackoverflow.com/questions/10701983/what-is-the-mime-type-for-markdown
59 | # Added by: avoidwork
60 | text/x-markdown markdown md mkd
61 |
62 | # What: ini files
63 | # Why: because they're just text files
64 | # Added by: Matthew Kastor
65 | text/plain ini
66 |
67 | # What: DASH Adaptive Streaming manifest
68 | # Why: https://developer.mozilla.org/en-US/docs/DASH_Adaptive_Streaming_for_HTML_5_Video
69 | # Added by: eelcocramer
70 | application/dash+xml mdp
71 |
72 | # What: OpenType font files - http://www.microsoft.com/typography/otspec/
73 | # Why: Browsers usually ignore the font MIME types and sniff the content,
74 | # but Chrome, shows a warning if OpenType fonts aren't served with
75 | # the `font/opentype` MIME type: http://i.imgur.com/8c5RN8M.png.
76 | # Added by: alrra
77 | font/opentype otf
78 |
79 | # What: Source Map files - https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1
80 | # Why: The entire file is a single JSON object, and the Google CDN already serves this MIME type: http://stackoverflow.com/questions/19911929/what-mime-type-should-i-use-for-source-map-files
81 | # Added by: zertosh
82 | application/json map
83 |
--------------------------------------------------------------------------------
/service/TestCallback.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 | module.exports = {
6 | auto_testEnhance : null,
7 | start : function(){
8 | await:
9 | var value = this.auto_testEnhance.callback_test1();
10 | await:
11 | var value2 = this.auto_testEnhance.callback_test1();
12 |
13 | console.log(" test callback1 ===================", value);
14 | console.log(" test callback2 ===================", value2);
15 | endawait;
16 | endawait;
17 | }
18 | };
19 |
--------------------------------------------------------------------------------
/service/TestEnhance.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 | module.exports = {
6 | callback_test1 : function(callback){
7 | var result = ' callback_test1 result value';
8 | setTimeout(function(){
9 | callback(result);
10 | },10000);
11 | },
12 | callback_test2 : function(p1,callback){
13 | var result = ' callback_test1 result value';
14 | setTimeout(function(){
15 | callback(result);
16 | },10000);
17 | },
18 | callback_test3 : function(p2,callback){
19 | var result = ' callback_test1 result value';
20 | setTimeout(function(){
21 | callback(result);
22 | },10000);
23 | }
24 | };
25 |
--------------------------------------------------------------------------------
/service/TestService.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 | module.exports = {
6 | f1 :'this f1',
7 | auto_xxx:null,
8 | auto_ip:null,
9 | postConstruct : function(){
10 | console.log('postConstruct',this.auto_xxx,this.auto_ip.id);
11 | this.testAop("hello");
12 | },
13 | preDestroy : function(){
14 | console.log('preDestroy');
15 | },
16 | testAop : function(str){
17 | console.log('this is TestService : ',str);
18 | }
19 | };
20 |
--------------------------------------------------------------------------------
/static/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | hello
--------------------------------------------------------------------------------
/static/test.js:
--------------------------------------------------------------------------------
1 | consoel.log('test load js')
--------------------------------------------------------------------------------
/static/新建文本文档.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/solq360/springnodejs/c3113229d03ca102ae18b3b4f8d06f1a40adeb8d/static/新建文本文档.txt
--------------------------------------------------------------------------------
/ws/aio.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 | module.exports = {
6 | value : ' v',
7 | '/aio':{
8 | controller : function(req, res,callback){
9 | var $this = this;
10 | setTimeout(function(){
11 | callback(555);
12 | console.log("aio end",$this.value);
13 | },10000);
14 | }
15 | },
16 | '/sync':{
17 | controller : function(req, res){
18 | var $this = this;
19 | setTimeout(function(){
20 | console.log("sync end",$this.value);
21 | },2000);
22 |
23 |
24 | return " sync end";
25 | }
26 | },
27 | '/sleep':{
28 | controller : function(req, res,callback){
29 | this.sleep(15000);
30 | return " sleep end";
31 | }
32 | },
33 |
34 |
35 | //private
36 | sleep : function(milliSecond) {
37 |
38 | var startTime = new Date().getTime();
39 |
40 | console.log(startTime);
41 |
42 | while(new Date().getTime() <= milliSecond + startTime) {
43 |
44 | }
45 |
46 | console.log(new Date().getTime());
47 | }
48 | };
49 |
--------------------------------------------------------------------------------
/ws/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 | var fs = require('fs'),
6 | queryUrl = require('url'),
7 | _error = require('../core/util/debug.js').error;
8 | debug = require('../core/util/debug.js').debug,
9 | webHelper = require('../core/util/WebHelper.js'),
10 | CacheQueue = require('../core/CacheQueue.js');
11 |
12 | module.exports = {
13 |
14 | '/':{
15 | controller : function(req){
16 | return 'xxx';
17 | }
18 | },
19 | '/index':{
20 | controller : function(){
21 | return {'code':200,data:{'xx':'测试中文'}};
22 | }
23 | }
24 | };
25 |
--------------------------------------------------------------------------------
/ws/ip.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 | module.exports = {
6 |
7 | postConstruct : function(){
8 | console.log('init ============================');
9 | },
10 |
11 | '/testpath':{
12 | auth : [],//权限
13 | controller : function(request, response){
14 | console.log("testpath",arguments);
15 | }
16 | },
17 | '/testpath/{p1}/{p2}':{
18 | auth : [],//权限
19 | controller : function(path_p2,path_p1){
20 | console.log("testpath==",arguments);
21 | }
22 | },
23 | '/testparam':{
24 | auth : [],//权限
25 | controller : function(param_p2,param_p1,body_xxx){
26 | console.log("testparam==",arguments);
27 | }
28 | },
29 | '/testpathParam/{p1}/{p2}':{
30 | auth : [],//权限
31 | controller : function(path_int_p2,path_p1,param_p1,param_p2){
32 | console.log("testpathParam",arguments);
33 | }
34 | },
35 | 'get|post:/test' :{
36 | controller : function(){
37 | console.log("test ============",arguments);
38 | }
39 |
40 | }
41 | };
42 |
--------------------------------------------------------------------------------
/ws/login.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @author solq
3 | * @deprecated blog: cnblogs.com/solq
4 | * */
5 | var _error = require('../core/util/debug.js').error;
6 | debug = require('../core/util/debug.js').debug;
7 |
8 | module.exports = {
9 | auto_sessionManager : null,
10 | auto_cookie : null,
11 | '/login':{
12 | controller : function(request,cookie){
13 | var session = this.auto_sessionManager.createSession(555);
14 | cookie.set(SessionKey.uuid , session.id );
15 | cookie.set("xxxxxx" , session.id );
16 | cookie.remove("value");
17 | debug("cookie ", cookie.valueOf() );
18 | session.close();
19 | }
20 | },
21 | '/session':{
22 | controller : function(request,cookie, session ){
23 |
24 |
25 | debug("session lastTime", session.getAttr(SessionKey.lastTime));
26 | }
27 | }
28 | };
29 |
--------------------------------------------------------------------------------
/ws/test/test1.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | '/sss':{
3 | auth : [],//权限
4 | methods : ['GET','POST'],
5 | controller : function(request, response){
6 | console.log("hello controller");
7 | }
8 | }
9 | };
10 |
--------------------------------------------------------------------------------