metosin / compojure-api

Sweet web apis with Compojure & Swagger
http://metosin.github.io/compojure-api/doc/
Eclipse Public License 1.0
1.11k stars 149 forks source link

Pull out static parts of an otherwise-dynamic context #466

Closed frenchy64 closed 3 months ago

frenchy64 commented 3 months ago

A bit of locals flow analysis might go a long way.

(context "/foo" a
  (GET "/bar" [] :query BigSchema (ok 1))
  (when (:something a)
    (POST "/bar" [] :query BigSchema (ok 1)))
=>
(let [route1 (GET "/bar" [] :query BigSchema (ok 1))
      route2 (POST "/bar" [] :query BigSchema (ok 1))]
  (context "/foo" a
    route1
    (when (:something a)
      route2)))