0001    //
0002    //  Context.swift
0003    //  Kunugi
0004    //
0005    //  Created by ito on 1/3/16.
0006    //  Copyright © 2016 Yusuke Ito. All rights reserved.
0007    //
0008    
0009    public protocol ContextBox
Context.swift:22
public extension ContextBox {
Context.swift:44
public extension ContextBox {
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:19
    func before(ctx: ContextBox) throws -> MiddlewareResult {
Controller.swift:22
    func after(ctx: ContextBox, result: MiddlewareResult) throws -> MiddlewareResult {
Controller.swift:25
    func handle(ctx: ContextBox) throws -> 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:33
    func shouldHandle(ctx: ContextBox) -> Bool
Middleware.swift:53
    func shouldHandle(ctx: ContextBox) -> Bool {
Middleware.swift:62
    public func shouldHandle(ctx: ContextBox) -> Bool {
Middleware.swift:67
public typealias MiddlewareHandler = ContextBox throws -> MiddlewareResult
Middleware.swift:71
    func handle(ctx: ContextBox) throws -> MiddlewareResult {
Router.swift:14
    func shouldHandle(ctx: ContextBox, path: String) -> Bool
Router.swift:15
    func rewriteBefore(ctx: ContextBox)
Router.swift:22
    func shouldHandle(ctx: ContextBox) -> Bool {
Router.swift:25
    func handle(ctx: ContextBox) throws -> MiddlewareResult {
Router.swift:36
    func rewriteBefore(ctx: ContextBox) {
Router.swift:96
    public func shouldHandle(ctx: ContextBox, path: String) -> Bool {
Router.swift:113
    public func rewriteBefore(ctx: ContextBox) {
Router.swift:132
    public func shouldHandle(ctx: ContextBox, path: String) -> Bool {
Router.swift:161
        func handle(ctx: ContextBox) throws -> MiddlewareResult {
Router.swift:203
    public func shouldHandle(ctx: ContextBox) -> Bool {
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: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 {
: class, CustomStringConvertible, CustomDebugStringConvertible { 0010 var context
Context.swift:27
        for c in context {
Context.swift:35
        for c in context {
Context.swift:40
        context.insert(ctx, atIndex: 0)
Context.swift:46
        return "\(context.map({ return $0.dynamicType.self }))"
Context.swift:49
        return "\(context)"
: [ContextType] { get set } 0011 0012 func get<T: ContextType>() throws -> T 0013 func put(ctx: ContextType) throws 0014 0015 var method
Controller.swift:29
            switch ctx.method {
Middleware.swift:54
        return methods.contains(ctx.method)
: Method { get set } 0016 var path
Router.swift:23
        return shouldHandle(ctx, path: ctx.path)
Router.swift:26
        let orig = ctx.path
Router.swift:31
            ctx.path = orig
Router.swift:37
        let newPath = rewritePath(ctx.path)
Router.swift:38
        if ctx.path == newPath {
Router.swift:41
        print("\(ctx.path) > \(newPath)(\(newPath.characters.count))")
Router.swift:42
        ctx.path = newPath
Router.swift:114
        let path = ctx.path
: String { get set } // current path 0017 var parameters
Router.swift:121
                ctx.parameters[k] = v
: [String: String] { get set } 0018 } 0019 0020 public protocol ContextType
Context.swift:10
    var context: [ContextType] { get set }
Context.swift:12
    func get<T: ContextType>() throws -> T
Context.swift:13
    func put(ctx: ContextType) throws
Context.swift:23
    func get<T: ContextType>() throws -> T {
Context.swift:34
    func put(ctx: ContextType) throws {
{ } 0021 0022 public extension ContextBox { 0023 func get<T: ContextType>() throws -> T { 0024 if let box = self as? T { 0025 return box 0026 } 0027 for c in context { 0028 if let cc = c as? T { 0029 return cc 0030 } 0031 } 0032 throw MiddlewareError.NoContextType("\(T.self)") 0033 } 0034 func put(ctx: ContextType) throws { 0035 for c in context { 0036 if c.dynamicType == ctx.dynamicType { 0037 throw MiddlewareError.AlreadyHasContextType("\(c.dynamicType)") 0038 } 0039 } 0040 context.insert(ctx, atIndex: 0) 0041 } 0042 } 0043 0044 public extension ContextBox { 0045 var description: String { 0046 return "\(context.map({ return $0.dynamicType.self }))" 0047 } 0048 var debugDescription: String { 0049 return "\(context)" 0050 } 0051 } 0052