   handler using the `delegate` function. Is a simple
   way to communicate the handlers chain."
   {:internal true :no-doc true}
-  [ctx]
-  (when-let [dc (-> (get-context* ctx)
-                    (hp/maybe-get DelegatedContext))]
-    (.-data dc)))
+  [context]
+  (let [^Context ctx (get-context* context)
+        ^DelegatedContext dctx (reg/maybe-get ctx DelegatedContext)]
+    (when dctx
+      (.-data dctx))))
 
 (defn delegate
   "Delegate handling to the next handler in line.

(defn create-context
  {:internal true}
  [^Context ctx]
  (let [holder (-> (.getRequest ctx)
                   (hp/maybe-get ContextHolder))]
    (merge (if holder
             (.-data ^ContextHolder holder)
             (build-context ctx))
           {:route-params (get-route-params ctx)}
           (get-context-params ctx))))


  "Functions and helpers for work in a clojure
  way with ratpack types."
  (:require [catacumba.impl.helpers :as hp]
            [catacumba.impl.registry :as reg]
            [promesa.core :as p])
  (:import catacumba.impl.DelegatedContext
           catacumba.impl.ContextHolder
