0

As we can call multiple handler from router get request, how do we pass, say the result computed in the first handler to the next handler block ?

// Uses multiple handler blocks
    router.get("/multi", handler: { request, response, next in
        response.send("I'm here!\n")
        next()
        }, { request, response, next in
            response.send("Me too!\n")
            next()
    })

1 Answers1

0

You can use the userInfo dictionary to hold computed data in the request object, and it'll be accessible in the subsequent handlers.

https://ibm-swift.github.io/Kitura/Classes/RouterRequest.html#/s:vC6Kitura13RouterRequest8userInfoGVs10DictionarySSP__

Youming Lin
  • 334
  • 2
  • 4