|
134 | 134 | (defn- wrap-route-info [handler route-info] |
135 | 135 | (fn |
136 | 136 | ([request] |
137 | | - (handler (assoc request :compojure/route route-info))) |
| 137 | + (handler (assoc request :compojure/route route-info |
| 138 | + :compojure/full-route (str (:compojure/context request) (second route-info))))) |
138 | 139 | ([request respond raise] |
139 | | - (handler (assoc request :compojure/route route-info) respond raise)))) |
| 140 | + (handler (assoc request :compojure/route route-info |
| 141 | + :compojure/full-route (str (:compojure/context request) (second route-info)) respond raise))))) |
140 | 142 |
|
141 | 143 | (defn- wrap-route-matches [handler method path] |
142 | 144 | (fn |
|
257 | 259 | path (:path-info request uri) |
258 | 260 | context (or (:context request) "") |
259 | 261 | subpath (:__path-info params) |
260 | | - params (dissoc params :__path-info)] |
| 262 | + params (dissoc params :__path-info) |
| 263 | + context-route (:context-route (meta route))] |
261 | 264 | (-> request |
262 | 265 | (assoc-route-params (decode-route-params params)) |
263 | 266 | (assoc :path-info (if (= subpath "") "/" subpath) |
264 | | - :context (remove-suffix uri subpath)))))) |
| 267 | + :context (remove-suffix uri subpath) |
| 268 | + :compojure/context (str (:compojure/context request) context-route)))))) |
265 | 269 |
|
266 | 270 | (defn- context-route [route] |
267 | 271 | (let [re-context {:__path-info #"|/.*"}] |
268 | | - (cond |
269 | | - (string? route) |
270 | | - (clout/route-compile (str route ":__path-info") re-context) |
271 | | - (and (vector? route) (literal? route)) |
272 | | - (clout/route-compile |
273 | | - (str (first route) ":__path-info") |
274 | | - (merge (apply hash-map (rest route)) re-context)) |
275 | | - (vector? route) |
276 | | - `(clout/route-compile |
277 | | - (str ~(first route) ":__path-info") |
278 | | - ~(merge (apply hash-map (rest route)) re-context)) |
279 | | - :else |
280 | | - `(clout/route-compile (str ~route ":__path-info") ~re-context)))) |
| 272 | + (cond |
| 273 | + (string? route) |
| 274 | + (with-meta (clout/route-compile (str route ":__path-info") re-context) {:context-route route}) |
| 275 | + (and (vector? route) (literal? route)) |
| 276 | + (with-meta (clout/route-compile |
| 277 | + (str (first route) ":__path-info") |
| 278 | + (merge (apply hash-map (rest route)) re-context)) {:context-route (first route)}) |
| 279 | + (vector? route) |
| 280 | + `(let [uncompiled-route# ~(first route)] |
| 281 | + (with-meta |
| 282 | + (clout/route-compile |
| 283 | + (str uncompiled-route# ":__path-info") |
| 284 | + ~(merge (apply hash-map (rest route)) re-context)) |
| 285 | + {:context-route uncompiled-route#})) |
| 286 | + :else |
| 287 | + `(let [path# ~route] |
| 288 | + (with-meta |
| 289 | + (clout/route-compile (str path# ":__path-info") ~re-context) |
| 290 | + (if (string? path#) |
| 291 | + {:context-route path#} |
| 292 | + {})))))) |
281 | 293 |
|
282 | 294 | (defn ^:no-doc make-context [route make-handler] |
283 | 295 | (letfn [(handler |
|
0 commit comments