0001    //
0002    //  Middleware1.swift
0003    //  todoapi
0004    //
0005    //  Created by ito on 1/2/16.
0006    //  Copyright © 2016 Yusuke Ito. All rights reserved.
0007    //
0008    
0009    import Nest
0010    
0011    public enum MiddlewareResult
Controller.swift:10
    func get(ctx: ContextBox) throws -> MiddlewareResult
Controller.swift:11
    func post(ctx: ContextBox) throws -> MiddlewareResult
Controller.swift:12
    func put(ctx: ContextBox) throws -> MiddlewareResult
Controller.swift:13
    func delete(ctx: ContextBox) throws -> MiddlewareResult
Controller.swift:14
    func before(ctx: ContextBox) throws -> MiddlewareResult
Controller.swift:15
    func after(ctx: ContextBox, result: MiddlewareResult) throws -> MiddlewareResult
Controller.swift:15
    func after(ctx: ContextBox, result: MiddlewareResult) throws -> MiddlewareResult
Controller.swift:19
    func before(ctx: ContextBox) throws -> MiddlewareResult {
Controller.swift:22
    func after(ctx: ContextBox, result: MiddlewareResult) throws -> MiddlewareResult {
Controller.swift:22
    func after(ctx: ContextBox, result: MiddlewareResult) throws -> MiddlewareResult {
Controller.swift:25
    func handle(ctx: ContextBox) throws -> MiddlewareResult {
Controller.swift:28
            let result: MiddlewareResult
Controller.swift:47
    func get(ctx: ContextBox) throws -> MiddlewareResult { return .Next }
Controller.swift:48
    func post(ctx: ContextBox) throws -> MiddlewareResult { return .Next }
Controller.swift:49
    func put(ctx: ContextBox) throws -> MiddlewareResult { return .Next }
Controller.swift:50
    func delete(ctx: ContextBox) throws -> MiddlewareResult { return .Next }
Middleware.swift:17
    func handle(ctx: ContextBox) throws -> MiddlewareResult
Middleware.swift:18
    func handleIfNeeded(ctx: ContextBox) throws -> MiddlewareResult
Middleware.swift:23
    public func handleIfNeeded(ctx: ContextBox) throws -> MiddlewareResult {
Middleware.swift:67
public typealias MiddlewareHandler = ContextBox throws -> MiddlewareResult
Middleware.swift:71
    func handle(ctx: ContextBox) throws -> MiddlewareResult {
Router.swift:25
    func handle(ctx: ContextBox) throws -> MiddlewareResult {
Router.swift:161
        func handle(ctx: ContextBox) throws -> MiddlewareResult {
Router.swift:206
    public func handle(ctx: ContextBox) throws -> MiddlewareResult {
WrapMiddleware.swift:10
    func handle(ctx: ContextBox, @noescape yieldNext: () throws -> MiddlewareResult) throws -> MiddlewareResult
WrapMiddleware.swift:10
    func handle(ctx: ContextBox, @noescape yieldNext: () throws -> MiddlewareResult) throws -> MiddlewareResult
WrapMiddleware.swift:11
    func genHandler(inner: MiddlewareType) -> (ContextBox throws -> MiddlewareResult)
WrapMiddleware.swift:15
    func genHandler(inner: MiddlewareType) -> (ContextBox throws -> MiddlewareResult) {
WrapMiddleware.swift:26
    func handle(ctx: ContextBox,  @noescape yieldNext: () throws -> MiddlewareResult ) throws -> MiddlewareResult {
WrapMiddleware.swift:26
    func handle(ctx: ContextBox,  @noescape yieldNext: () throws -> MiddlewareResult ) throws -> MiddlewareResult {
{ 0012 case Next
Composer.swift:24
            case .Next:
Composer.swift:30
        return .Next
Controller.swift:20
        return .Next
Controller.swift:27
        case .Next:
Controller.swift:39
                result = .Next
Controller.swift:47
    func get(ctx: ContextBox) throws -> MiddlewareResult { return .Next }
Controller.swift:48
    func post(ctx: ContextBox) throws -> MiddlewareResult { return .Next }
Controller.swift:49
    func put(ctx: ContextBox) throws -> MiddlewareResult { return .Next }
Controller.swift:50
    func delete(ctx: ContextBox) throws -> MiddlewareResult { return .Next }
Middleware.swift:25
            return .Next
Router.swift:30
        case .Next:
Router.swift:155
    var outer: MiddlewareType = GenericMiddleware { ctx in .Next }
0013 case Respond(ResponseType) 0014 } 0015 0016 public protocol MiddlewareType
Application.swift:11
    var middleware: [MiddlewareType] { get }
Application.swift:12
    var handler: MiddlewareType { get }
Application.swift:17
    var handler: MiddlewareType {
Composer.swift:12
public func >>>(a: MiddlewareType, b: MiddlewareType) -> MiddlewareType {
Composer.swift:12
public func >>>(a: MiddlewareType, b: MiddlewareType) -> MiddlewareType {
Composer.swift:12
public func >>>(a: MiddlewareType, b: MiddlewareType) -> MiddlewareType {
Composer.swift:16
public func compose(middewares: MiddlewareType...) -> MiddlewareType {
Composer.swift:16
public func compose(middewares: MiddlewareType...) -> MiddlewareType {
Composer.swift:20
public func compose(middewares: [MiddlewareType]) -> MiddlewareType {
Composer.swift:20
public func compose(middewares: [MiddlewareType]) -> MiddlewareType {
Controller.swift:9
public protocol ControllerMiddleware: MiddlewareType {
Middleware.swift:21
public extension MiddlewareType {
Middleware.swift:69
struct GenericMiddleware: MiddlewareType, AnyRequestHandleable {
Router.swift:11
public protocol RouteWrap: MiddlewareType {
Router.swift:12
    var inner: MiddlewareType { get }
Router.swift:95
    public let inner: MiddlewareType
Router.swift:105
    public init(_ path: String, _ inner: MiddlewareType) {
Router.swift:130
    public let inner: MiddlewareType
Router.swift:148
    public init(_ prefix: String, _ inner: MiddlewareType) {
Router.swift:154
public class Router: MiddlewareType {
Router.swift:155
    var outer: MiddlewareType = GenericMiddleware { ctx in .Next }
Router.swift:156
    var routes: [MiddlewareType] = []
Router.swift:158
    struct MethodMiddleware: MethodHandleable, MiddlewareType {
WrapMiddleware.swift:11
    func genHandler(inner: MiddlewareType) -> (ContextBox throws -> MiddlewareResult)
WrapMiddleware.swift:15
    func genHandler(inner: MiddlewareType) -> (ContextBox throws -> MiddlewareResult) {
: MiddlewareHandleable { 0017 func handle
Middleware.swift:27
        return try handle(ctx)
Router.swift:207
        return try outer.handle(ctx)
(ctx: ContextBox) throws -> MiddlewareResult 0018 func handleIfNeeded
Application.swift:23
            return try current.handleIfNeeded(ctx)
Composer.swift:23
            switch try m.handleIfNeeded(ctx) {
Router.swift:28
        let res = try inner.handleIfNeeded(ctx)
WrapMiddleware.swift:18
                return try inner.handleIfNeeded(ctx)
WrapMiddleware.swift:21
                return try inner.handleIfNeeded(ctx)
(ctx: ContextBox) throws -> MiddlewareResult 0019 } 0020 0021 public extension MiddlewareType { 0022 0023 public func handleIfNeeded(ctx: ContextBox) throws -> MiddlewareResult { 0024 guard shouldHandle(ctx) else { 0025 return .Next 0026 } 0027 return try handle(ctx) 0028 } 0029 } 0030 0031 0032 public protocol MiddlewareHandleable
Middleware.swift:16
public protocol MiddlewareType: MiddlewareHandleable {
Middleware.swift:38
public protocol MethodHandleable: MiddlewareHandleable {
Middleware.swift:58
public protocol AnyRequestHandleable: MiddlewareHandleable {
WrapMiddleware.swift:9
public protocol WrapMiddleware: MiddlewareHandleable {
{ 0033 func shouldHandle
Middleware.swift:24
        guard shouldHandle(ctx) else {
Router.swift:204
        return outer.shouldHandle(ctx)
WrapMiddleware.swift:17
            if self.shouldHandle(ctx) == false {
(ctx: ContextBox) -> Bool 0034 } 0035 0036 0037 0038 public protocol MethodHandleable
Middleware.swift:42
public extension MethodHandleable {
Router.swift:158
    struct MethodMiddleware: MethodHandleable, MiddlewareType {
: MiddlewareHandleable { 0039 var methods
Middleware.swift:54
        return methods.contains(ctx.method)
: Set<Method> { get } 0040 } 0041 0042 public extension MethodHandleable { 0043 var methods: Set<Method> { 0044 return Set([ 0045 .DELETE, 0046 .GET, 0047 .HEAD, 0048 .POST, 0049 .PUT, 0050 .OPTIONS 0051 ]) 0052 } 0053 func shouldHandle(ctx: ContextBox) -> Bool { 0054 return methods.contains(ctx.method) 0055 } 0056 } 0057 0058 public protocol AnyRequestHandleable
Middleware.swift:61
public extension AnyRequestHandleable {
Middleware.swift:69
struct GenericMiddleware: MiddlewareType, AnyRequestHandleable {
: MiddlewareHandleable { 0059 } 0060 0061 public extension AnyRequestHandleable { 0062 public func shouldHandle(ctx: ContextBox) -> Bool { 0063 return true 0064 } 0065 } 0066 0067 public typealias MiddlewareHandler
Middleware.swift:70
    let handler: MiddlewareHandler
Router.swift:160
        let handler: MiddlewareHandler
Router.swift:171
    func handle(methods: Set<Method>, path: String, handler: MiddlewareHandler) {
Router.swift:176
    public func all(path: String, _ handler: MiddlewareHandler) {
Router.swift:187
    public func get(path: String, _ handler: MiddlewareHandler) {
Router.swift:191
    public func post(path: String, _ handler: MiddlewareHandler) {
Router.swift:195
    public func put(path: String, _ handler: MiddlewareHandler) {
Router.swift:199
    public func delete(path: String, _ handler: MiddlewareHandler) {
= ContextBox throws -> MiddlewareResult 0068 0069 struct GenericMiddleware
Application.swift:18
        return GenericMiddleware { ctx in
Application.swift:21
                current = GenericMiddleware(handler: m.genHandler(current))
Composer.swift:21
    return GenericMiddleware { ctx in
Router.swift:155
    var outer: MiddlewareType = GenericMiddleware { ctx in .Next }
: MiddlewareType, AnyRequestHandleable { 0070 let handler
Middleware.swift:72
        return try handler(ctx)
: MiddlewareHandler 0071 func handle(ctx: ContextBox) throws -> MiddlewareResult { 0072 return try handler(ctx) 0073 } 0074 } 0075 0076 0077