0001 // 0002 // WrapMiddleware.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 WrapMiddleware: MiddlewareHandleable { 0010 func handle
Application.swift:10 var wrap: [WrapMiddleware] { get }WrapMiddleware.swift:14 public extension WrapMiddleware {(ctx: ContextBox, @noescape yieldNext: () throws -> MiddlewareResult) throws -> MiddlewareResult 0011 func genHandler
WrapMiddleware.swift:20 return try self.handle(ctx, yieldNext: {(inner: MiddlewareType) -> (ContextBox throws -> MiddlewareResult) 0012 } 0013 0014 public extension WrapMiddleware { 0015 func genHandler(inner: MiddlewareType) -> (ContextBox throws -> MiddlewareResult) { 0016 return { ctx in 0017 if self.shouldHandle(ctx) == false { 0018 return try inner.handleIfNeeded(ctx) 0019 } 0020 return try self.handle(ctx, yieldNext: { 0021 return try inner.handleIfNeeded(ctx) 0022 }) 0023 } 0024 } 0025 0026 func handle(ctx: ContextBox, @noescape yieldNext: () throws -> MiddlewareResult ) throws -> MiddlewareResult { 0027 return try yieldNext() 0028 } 0029 } 0030
Application.swift:21 current = GenericMiddleware(handler: m.genHandler(current))