Fork me on GitHub
#yada
<
2016-10-13
>
Rachel Westmacott16:10:42

Is it possible to call bidi/vhosts-model without knowing the host name?

malcolmsparks17:10:15

Yes. Specify a wildcard, see bidi's README

Rachel Westmacott19:10:09

If I try this:

(vhosts-model [:*
                                        ["/index.html" :index]
                                        ["login" :login]])

Rachel Westmacott19:10:32

I get: ExceptionInfo Error in server model: [[(named (not (sequential? :*)) "Virtual host") nil nil]]

dominicm20:10:41

Does it need to be (vhosts-model [[:*] ...])

Rachel Westmacott20:10:01

ExceptionInfo Error in server model: [[(named [(not (map? :*))] "Virtual host") nil nil]]

Rachel Westmacott20:10:12

which I think might be the same error

Rachel Westmacott20:10:02

I’ve been through a few iterations of randomly re-arranging square brackets, but it feels like a mug’s game.

dominicm20:10:45

I hadn't actually looked at the readme, what you did should have worked. ¯\(ツ)

malcolmsparks21:10:55

All I can suggest is that you might be on an old version of bidi, or an old one is getting linked - can you try lein deps :tree to make sure you've got bidi 2.0.12

malcolmsparks21:10:22

@peterwestmacott sorry for your frustration, the wildcard feature is recent so there might be a bug but I've retested on my system and all seems ok

malcolmsparks21:10:11

I hoping clojure.spec will make these errors a little less arduous

malcolmsparks21:10:46

Once you're sure you're on the latest bidi, send me a bit more code with context and I'll try it here

Rachel Westmacott21:10:25

definitely 2.0.12

Rachel Westmacott21:10:47

I’ll try and come up with a minimal test case

Rachel Westmacott21:10:04

okay, so I ran lein new test-bidi to create a new project, modified the dependencies in the project.clj file to be:

Rachel Westmacott21:10:07

:dependencies [[org.clojure/clojure "1.8.0"]
                 [bidi "2.0.12”]]

Rachel Westmacott21:10:22

fired up a REPL in cursive and ran

Rachel Westmacott21:10:32

(require '[bidi.vhosts :refer [vhosts-model]])

Rachel Westmacott21:10:44

(vhosts-model
  [:*
   ["/index.html" :index]
   ["/login" :login]])

Rachel Westmacott21:10:04

and got: ExceptionInfo Error in server model: [[(named (not (sequential? :*)) "Virtual host") nil nil]] clojure.core/ex-info (core.clj:4617)

Rachel Westmacott21:10:37

I should maybe add that I can inject the server name through an environment variable if I need to. So there is definitely a workaround here.