narkisr-deprecated / swag

A DSL for documenting Compojure routes using Swagger spec
23 stars 3 forks source link

how to change basepath? #3

Closed daroay closed 11 years ago

daroay commented 11 years ago

I tried with (binding [base "http://..."] ( -> ...start example application... ) )

but no luck

daroay commented 11 years ago

Ok, followed this post: http://stackoverflow.com/questions/10986293/how-to-set-a-dynamic-var-in-another-namespace

and did it with: (alter-var-root #'base (constantly "http://"))

This is supposedly exposed to all threads. Is there a better way?

I'm 4 days newbie on clojure

narkisr commented 11 years ago

The reason binding won't work is because the base path is used right after the macro expansion takes place in defroutes, if you set the alter before those it should be set.

Iv introduced set-base which uses an atom to do the same, in addition an exception will thrown if no base path was set before using defroutes-

Thanks