1 /*
2  * Archttp - A highly performant web framework written in D.
3  *
4  * Copyright (C) 2021-2022 Kerisy.com
5  *
6  * Website: https://www.kerisy.com
7  *
8  * Licensed under the Apache-2.0 License.
9  *
10  */
11 
12 module archttp.Route;
13 
14 import archttp.HttpMethod;
15 
16 import std.stdio;
17 
18 class Route(RoutingHandler)
19 {
20     private
21     {
22         string _path;
23 
24         RoutingHandler[HttpMethod] _handlers;
25     }
26 
27     public
28     {
29         // like uri path
30         string pattern;
31 
32         // use regex?
33         bool regular;
34 
35         // Regex template
36         string urlTemplate;
37 
38         string[uint] paramKeys;
39     }
40     
41     this(string path, HttpMethod method, RoutingHandler handler)
42     {
43         _path = path;
44         _handlers[method] = handler;
45     }
46 
47     RoutingHandler find(HttpMethod method)
48     {
49         auto handler = _handlers.get(method, null);
50 
51         return cast(RoutingHandler) handler;
52     }
53 
54     string path()
55     {
56         return _path;
57     }
58 }