|
15 | 15 | import HTTPTypes |
16 | 16 |
|
17 | 17 | /// A Trie router implementation |
18 | | -public struct TrieRouter: LambdaOpenAPIRouter { |
| 18 | +public struct TrieRouter: OpenAPILambdaRouter { |
19 | 19 | private let uriPath: URIPathCollection = URIPath() |
20 | 20 |
|
21 | 21 | /// add a route for a given HTTP method and path and associate a handler |
@@ -88,16 +88,16 @@ struct URIPath: URIPathCollection { |
88 | 88 | /// - the OpenAPIHandler for this path |
89 | 89 | /// - the OpenAI ServerRequestMetadata (a [String:String] with parameter names and their values |
90 | 90 | /// - Throws: |
91 | | - /// - LambdaOpenAPIRouterError.noRouteForPath when there is no handler in the graph for the given combination of HTTP method and path |
92 | | - /// - LambdaOpenAPIRouterError.noRouteForMethod when there is no handler for that HTTP method |
93 | | - /// - LambdaOpenAPIRouterError.noHandlerForPath when there is no handler as leaf node of the tree. This is a programming error and should not happen |
| 91 | + /// - OpenAPILambdaRouterError.noRouteForPath when there is no handler in the graph for the given combination of HTTP method and path |
| 92 | + /// - OpenAPILambdaRouterError.noRouteForMethod when there is no handler for that HTTP method |
| 93 | + /// - OpenAPILambdaRouterError.noHandlerForPath when there is no handler as leaf node of the tree. This is a programming error and should not happen |
94 | 94 | func find(method: HTTPRequest.Method, path: String) throws -> (OpenAPIHandler, OpenAPILambdaRequestParameters) { |
95 | 95 | var parameters: OpenAPILambdaRequestParameters = [:] |
96 | 96 | let root: Node = root() |
97 | 97 |
|
98 | 98 | // first node is the HTTP Method |
99 | 99 | guard let nodeHTTP = root.children[method.rawValue] else { |
100 | | - throw LambdaOpenAPIRouterError.noRouteForMethod(method) |
| 100 | + throw OpenAPILambdaRouterError.noRouteForMethod(method) |
101 | 101 | } |
102 | 102 |
|
103 | 103 | // search for each path component. If a component is not found, it might be a parameter |
@@ -125,18 +125,18 @@ struct URIPath: URIPathCollection { |
125 | 125 | currentNode = child |
126 | 126 | } |
127 | 127 | else { |
128 | | - throw LambdaOpenAPIRouterError.noRouteForPath(path) |
| 128 | + throw OpenAPILambdaRouterError.noRouteForPath(path) |
129 | 129 | } |
130 | 130 | } |
131 | 131 | } |
132 | 132 |
|
133 | 133 | //at this stage, current node must have a handler child |
134 | 134 | guard let handlerNode = currentNode.handlerChild() else { |
135 | | - throw LambdaOpenAPIRouterError.noHandlerForPath(path) |
| 135 | + throw OpenAPILambdaRouterError.noHandlerForPath(path) |
136 | 136 | } |
137 | 137 |
|
138 | 138 | // did we found an handler ? |
139 | | - guard let handler = handlerNode.value.handler else { throw LambdaOpenAPIRouterError.noHandlerForPath(path) } |
| 139 | + guard let handler = handlerNode.value.handler else { throw OpenAPILambdaRouterError.noHandlerForPath(path) } |
140 | 140 | return (handler, parameters) |
141 | 141 | } |
142 | 142 |
|
|
0 commit comments