1 module hunt.framework.routing.RouteItem;
2 
3 import hunt.framework.middleware.MiddlewareInterface;
4 import hunt.logging;
5 
6 
7 /**
8  * 
9  */
10 class RouteItem {
11     private TypeInfo_Class[] _allowedMiddlewares;
12     private TypeInfo_Class[] _skippedMiddlewares;
13 
14     string[] methods;
15 
16     string path;
17     string urlTemplate;
18     string pattern;
19     string[int] paramKeys;
20 
21     bool isRegex = false;
22 
23     void withMiddleware(T)() if(is(T : MiddlewareInterface)) {
24         _allowedMiddlewares ~= T.classinfo;
25     }
26 
27     void withMiddleware(string name) {
28         try {
29             TypeInfo_Class typeInfo = MiddlewareInterface.get(name);
30             _allowedMiddlewares ~= typeInfo;
31         } catch(Exception ex) {
32             warning(ex.msg);
33         }
34     }
35 
36     TypeInfo_Class[] allowedMiddlewares() {
37         return _allowedMiddlewares;
38     }
39 
40     void withoutMiddleware(T)() if(is(T : MiddlewareInterface)) {
41         _skippedMiddlewares ~= T.classinfo;
42     }
43 
44     void withoutMiddleware(string name) {
45         try {
46             TypeInfo_Class typeInfo = MiddlewareInterface.get(name);
47             _skippedMiddlewares ~= typeInfo;
48         } catch(Exception ex) {
49             warning(ex.msg);
50         }
51     }
52 
53     TypeInfo_Class[] skippedMiddlewares() {
54         return _skippedMiddlewares;
55     }
56 
57 
58 }