0

I'm a newbie with pedestal (pedestal.io) and I am trying to proxy all the requests I get from a browser, except a few specific ones which need some extra interceptors. These are my routes:

(def routes #{
           ["/*proxy" :any [(proxy-handler (server :dan-server))]]
           ["/service/storyboard/StoryboardLayer/auto" :post [dummy-interceptor (proxy-handler (server :dan-server))] :route-name :save-layer-route]
           })

However I never get the dummy-interceptor called. How should these be combined?

Dan Bunea
  • 187
  • 1
  • 2
  • 10

1 Answers1

0

The problem is described here as well: https://github.com/pedestal/pedestal/issues/532#issuecomment-324881362

"My understanding of http://pedestal.io/reference/routing-quick-reference is that this is intentional: 'wildcard routes always win over explicit paths in the same subtree'. A wildcard route at the root wins over everything else."

Fix

At the bottom of the page, http://pedestal.io/reference/routing-quick-reference it says we need to say which router to use, one is :linear-router

So to fix it, I added in my service map, later used to create-server

(def service {
          ...
          ::http/router :linear-search

And now, it works, if I switch the routes, since they are being analysed in order (linear).

(def routes #{
       ["/service/storyboard/StoryboardLayer/auto" :post [dummy-interceptor (proxy-handler (server :dan-server))] :route-name :save-layer-route]
       ["/*proxy" :any [(proxy-handler (server :dan-server))]]
       })
Dan Bunea
  • 187
  • 1
  • 2
  • 10