Skip to content

Commit

Permalink
#15 Refactored if statement in process
Browse files Browse the repository at this point in the history
  • Loading branch information
dfirsht committed Mar 1, 2016
1 parent dfb9976 commit e2b2a11
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions KituraRouter/RouterElement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,24 +126,29 @@ class RouterElement {
/// - Parameter response: the response
///
func process(httpMethod: RouterMethod, urlPath: NSData, request: RouterRequest, response: RouterResponse, next: () -> Void) {
if (response.error == nil && (method == .All || method == httpMethod)) || (response.error != nil && method == .Error) {
if let r = regex {
let matcher = r.matcher!
if matcher.match(urlPath) {
if response.error == nil || method == .Error {
if response.error != nil || method == .All || method == httpMethod {
// Either response error exists and method is error, or method matches
if let r = regex {
let matcher = r.matcher!
if matcher.match(urlPath) {
request.route = pattern
updateRequestParams(matcher, request: request)
processHelper(request, response: response, next: next)
} else {
next()
}
}
else {
request.route = pattern
updateRequestParams(matcher, request: request)
request.params = [:]
processHelper(request, response: response, next: next)
} else {
next()
}
}
else {
request.route = pattern
request.params = [:]
processHelper(request, response: response, next: next)
} else {
next ()
}
} else {
next()
next ()
}
}

Expand Down

0 comments on commit e2b2a11

Please sign in to comment.