<commit_before>//
//  RouteHandler.swift
//  Switchboard
//
//  Created by <NAME> on 2/22/16.
//  Copyright © 2016 Nougat. All rights reserved.
//

import Foundation

protocol RouteHandlingType {
    
    func perform(request: MatchedRequest) -> Response?
    
}

struct RouteHandlerWithNoArgs: RouteHandlingType {
    
    private let handler: (MatchedRequest) -> Response
    init(handler: (MatchedRequest) -> Response) {
        self.handler = handler
    }
    
    func perform(request: MatchedRequest) -> Response? {
        return handler(request)
    }
    
}

struct RouteHandlerWithOneArg<A: PathType>: RouteHandlingType {
    
    private let handler: (MatchedRequest, A) -> Response
    init(handler: (MatchedRequest, A) -> Response) {
        self.handler = handler
    }
    
    func perform(request: MatchedRequest) -> Response? {
        guard let param1: A = request.paramAtIndex(0) else { return nil }
        return handler(request, param1)
    }
    
}

struct RouteHandlerWithTwoArgs<A: PathType, B: PathType>: RouteHandlingType {
    
    private let handler: (MatchedRequest, A, B) -> Response
    init(handler: (MatchedRequest, A, B) -> Response) {
        self.handler = handler
    }
    
    func perform(request: MatchedRequest) -> Response? {
        guard let param1: A = request.paramAtIndex(0),
              let param2: B = request.paramAtIndex(1) else { return nil }
        return handler(request, param1, param2)
    }
    
}<commit_msg>Pass a Request to the handler instead of a MatchedRequest.<commit_after>//
//  RouteHandler.swift
//  Switchboard
//
//  Created by <NAME> on 2/22/16.
//  Copyright © 2016 Nougat. All rights reserved.
//

import Foundation

protocol RouteHandlingType {
    
    func perform(request: MatchedRequest) -> Response?
    
}

struct RouteHandlerWithNoArgs: RouteHandlingType {
    
    private let handler: (Request) -> Response
    init(handler: (Request) -> Response) {
        self.handler = handler
    }
    
    func perform(request: MatchedRequest) -> Response? {
        return handler(request.request)
    }
    
}

struct RouteHandlerWithOneArg<A: PathType>: RouteHandlingType {
    
    private let handler: (Request, A) -> Response
    init(handler: (Request, A) -> Response) {
        self.handler = handler
    }
    
    func perform(request: MatchedRequest) -> Response? {
        guard let param1: A = request.paramAtIndex(0) else { return nil }
        return handler(request.request, param1)
    }
    
}

struct RouteHandlerWithTwoArgs<A: PathType, B: PathType>: RouteHandlingType {
    
    private let handler: (Request, A, B) -> Response
    init(handler: (Request, A, B) -> Response) {
        self.handler = handler
    }
    
    func perform(request: MatchedRequest) -> Response? {
        guard let param1: A = request.paramAtIndex(0),
              let param2: B = request.paramAtIndex(1) else { return nil }
        return handler(request.request, param1, param2)
    }
    
}
{'fraction_non_alphanumeric': 0.10756302521008404, 'fraction_numerical': 0.012100840336134453, 'mean_word_length': 2.656019656019656, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2196748', 'n_tokens_mistral': 896, 'n_tokens_neox': 872, 'n_words': 235}