0001 public class Route{ 0002 0003 static var routes
Application.swift:10 private let routeManager: HandlerManager<Route>Application.swift:26 routeManager = HandlerManager<Route>(allowsMultiplesPerPath: false)Application.swift:122 for route in Route.routes {Application.swift:177 Route.createRoutesFromRouter(router, withPath: path)Application.swift:187 Route.createRoutesFromRouter(router, withPath: path)Application.swift:220 public func get(path: String, handler: Route.Handler) {Application.swift:221 Route.get(path, handler: handler)Application.swift:224 public func put(path: String, handler: Route.Handler) {Application.swift:225 Route.put(path, handler: handler)Application.swift:228 public func delete(path: String, handler: Route.Handler) {Application.swift:229 Route.delete(path, handler: handler)Application.swift:232 public func post(path: String, handler: Route.Handler) {Application.swift:233 Route.post(path, handler: handler)Application.swift:236 public func patch(path: String, handler: Route.Handler) {Application.swift:237 Route.patch(path, handler: handler)Application.swift:240 public func all(path: String, handler: Route.Handler) {Application.swift:241 Route.all(path, handler: handler)Route.swift:3 static var routes: [Route] = []Route.swift:27 let route = Route(method: method, path: path, handler: handler)Route.swift:70 extension Route: Handler {Router.swift:4 func get(path: String, handler: Route.Handler)Router.swift:5 func put(path: String, handler: Route.Handler)Router.swift:6 func delete(path: String, handler: Route.Handler)Router.swift:7 func post(path: String, handler: Route.Handler)Router.swift:8 func patch(path: String, handler: Route.Handler)Router.swift:9 func all(path: String, handler: Route.Handler)Router.swift:15 var gets: [String: Route.Handler] = [:]Router.swift:16 var puts: [String: Route.Handler] = [:]Router.swift:17 var deletes: [String: Route.Handler] = [:]Router.swift:18 var posts: [String: Route.Handler] = [:]Router.swift:19 var patches: [String: Route.Handler] = [:]Router.swift:20 var alls: [String: Route.Handler] = [:]Router.swift:34 final public func get(path: String, handler: Route.Handler) {Router.swift:38 final public func put(path: String, handler: Route.Handler) {Router.swift:42 final public func delete(path: String, handler: Route.Handler) {Router.swift:46 final public func post(path: String, handler: Route.Handler) {Router.swift:50 final public func patch(path: String, handler: Route.Handler) {Router.swift:54 public func all(path: String, handler: Route.Handler) {: [Route] = [] 0004 0005 public typealias Handler
Application.swift:122 for route in Route.routes {Route.swift:28 self.routes.append(route)= ((request: Request, response: Response) -> Void) 0006 0007 let method
Application.swift:220 public func get(path: String, handler: Route.Handler) {Application.swift:224 public func put(path: String, handler: Route.Handler) {Application.swift:228 public func delete(path: String, handler: Route.Handler) {Application.swift:232 public func post(path: String, handler: Route.Handler) {Application.swift:236 public func patch(path: String, handler: Route.Handler) {Application.swift:240 public func all(path: String, handler: Route.Handler) {Route.swift:9 let handler: HandlerRoute.swift:11 init(method: Request.Method, path: String, handler: Handler) {Route.swift:26 class func add(method method: Request.Method, path: String, handler: Handler) {Route.swift:31 class func addHandlers(handlers: [String: Handler],Route.swift:32 toRoutesWithFunction function: ((path: String, handler: Handler) -> Void),Route.swift:40 class func get(path: String, handler: Handler) {Route.swift:44 class func post(path: String, handler: Handler) {Route.swift:48 class func put(path: String, handler: Handler) {Route.swift:52 class func patch(path: String, handler: Handler) {Route.swift:56 class func delete(path: String, handler: Handler) {Route.swift:60 class func all(path: String, handler: Handler) {Router.swift:4 func get(path: String, handler: Route.Handler)Router.swift:5 func put(path: String, handler: Route.Handler)Router.swift:6 func delete(path: String, handler: Route.Handler)Router.swift:7 func post(path: String, handler: Route.Handler)Router.swift:8 func patch(path: String, handler: Route.Handler)Router.swift:9 func all(path: String, handler: Route.Handler)Router.swift:15 var gets: [String: Route.Handler] = [:]Router.swift:16 var puts: [String: Route.Handler] = [:]Router.swift:17 var deletes: [String: Route.Handler] = [:]Router.swift:18 var posts: [String: Route.Handler] = [:]Router.swift:19 var patches: [String: Route.Handler] = [:]Router.swift:20 var alls: [String: Route.Handler] = [:]Router.swift:34 final public func get(path: String, handler: Route.Handler) {Router.swift:38 final public func put(path: String, handler: Route.Handler) {Router.swift:42 final public func delete(path: String, handler: Route.Handler) {Router.swift:46 final public func post(path: String, handler: Route.Handler) {Router.swift:50 final public func patch(path: String, handler: Route.Handler) {Router.swift:54 public func all(path: String, handler: Route.Handler) {: Request.Method 0008 let path
Application.swift:124 self.routeManager.register(route.method.rawValue, handler: route)Route.swift:12 self.method = method: String 0009 let handler
Route.swift:13 self.path = pathRoute.swift:74 let routePaths = self.path.split("?")[0].split("/"): Handler 0010 0011 init
Route.swift:14 self.handler = handlerRoute.swift:89 self.handler(request: request, response: response)(method: Request.Method, path: String, handler: Handler) { 0012 self.method = method 0013 self.path = path 0014 self.handler = handler 0015 } 0016 0017 class func createRoutesFromRouter
Route.swift:27 let route = Route(method: method, path: path, handler: handler)(router: Router, withPath path: String) { 0018 addHandlers(router.gets, toRoutesWithFunction: get, withPath: path) 0019 addHandlers(router.posts, toRoutesWithFunction: post, withPath: path) 0020 addHandlers(router.puts, toRoutesWithFunction: put, withPath: path) 0021 addHandlers(router.deletes, toRoutesWithFunction: delete, withPath: path) 0022 addHandlers(router.patches, toRoutesWithFunction: patch, withPath: path) 0023 addHandlers(router.alls, toRoutesWithFunction: all, withPath: path) 0024 } 0025 0026 class func add
Application.swift:177 Route.createRoutesFromRouter(router, withPath: path)Application.swift:187 Route.createRoutesFromRouter(router, withPath: path)(method method: Request.Method, path: String, handler: Handler) { 0027 let route = Route(method: method, path: path, handler: handler) 0028 self.routes.append(route) 0029 } 0030 0031 class func addHandlers
Route.swift:41 self.add(method: .Get, path: path, handler: handler)Route.swift:45 self.add(method: .Post, path: path, handler: handler)Route.swift:49 self.add(method: .Put, path: path, handler: handler)Route.swift:53 self.add(method: .Patch, path: path, handler: handler)Route.swift:57 self.add(method: .Delete, path: path, handler: handler)(handlers: [String: Handler], 0032 toRoutesWithFunction function: ((path: String, handler: Handler) -> Void), 0033 withPath path: String) { 0034 for (postPath, handler) in handlers { 0035 let fullPath = "\(path)\(postPath)" 0036 function(path: fullPath, handler: handler) 0037 } 0038 } 0039 0040 class func get
Route.swift:18 addHandlers(router.gets, toRoutesWithFunction: get, withPath: path)Route.swift:19 addHandlers(router.posts, toRoutesWithFunction: post, withPath: path)Route.swift:20 addHandlers(router.puts, toRoutesWithFunction: put, withPath: path)Route.swift:21 addHandlers(router.deletes, toRoutesWithFunction: delete, withPath: path)Route.swift:22 addHandlers(router.patches, toRoutesWithFunction: patch, withPath: path)Route.swift:23 addHandlers(router.alls, toRoutesWithFunction: all, withPath: path)(path: String, handler: Handler) { 0041 self.add(method: .Get, path: path, handler: handler) 0042 } 0043 0044 class func post
Application.swift:221 Route.get(path, handler: handler)Route.swift:18 addHandlers(router.gets, toRoutesWithFunction: get, withPath: path)Route.swift:61 self.get(path, handler: handler)(path: String, handler: Handler) { 0045 self.add(method: .Post, path: path, handler: handler) 0046 } 0047 0048 class func put
Application.swift:233 Route.post(path, handler: handler)Route.swift:19 addHandlers(router.posts, toRoutesWithFunction: post, withPath: path)Route.swift:62 self.post(path, handler: handler)(path: String, handler: Handler) { 0049 self.add(method: .Put, path: path, handler: handler) 0050 } 0051 0052 class func patch
Application.swift:225 Route.put(path, handler: handler)Route.swift:20 addHandlers(router.puts, toRoutesWithFunction: put, withPath: path)Route.swift:63 self.put(path, handler: handler)(path: String, handler: Handler) { 0053 self.add(method: .Patch, path: path, handler: handler) 0054 } 0055 0056 class func delete
Application.swift:237 Route.patch(path, handler: handler)Route.swift:22 addHandlers(router.patches, toRoutesWithFunction: patch, withPath: path)Route.swift:64 self.patch(path, handler: handler)(path: String, handler: Handler) { 0057 self.add(method: .Delete, path: path, handler: handler) 0058 } 0059 0060 class func all
Application.swift:229 Route.delete(path, handler: handler)Route.swift:21 addHandlers(router.deletes, toRoutesWithFunction: delete, withPath: path)Route.swift:65 self.delete(path, handler: handler)(path: String, handler: Handler) { 0061 self.get(path, handler: handler) 0062 self.post(path, handler: handler) 0063 self.put(path, handler: handler) 0064 self.patch(path, handler: handler) 0065 self.delete(path, handler: handler) 0066 } 0067 0068 } 0069 0070 extension Route: Handler { 0071 func handle(request request: Request, response: Response, next: (() -> ())) { 0072 0073 // Grab request params 0074 let routePaths = self.path.split("?")[0].split("/") 0075 0076 for (index, path) in routePaths.enumerate() { 0077 if path.hasPrefix(":") { 0078 let requestPaths = request.path.split("/") 0079 if requestPaths.count > index { 0080 var trimPath = path 0081 trimPath.removeAtIndex(path.startIndex) 0082 request.parameters[trimPath] = requestPaths[index] 0083 } 0084 } 0085 } 0086 0087 Session.start(request) 0088 0089 self.handler(request: request, response: response) 0090 0091 } 0092 } 0093
Application.swift:241 Route.all(path, handler: handler)Route.swift:23 addHandlers(router.alls, toRoutesWithFunction: all, withPath: path)