Fork me on GitHub
#luminus
<
2018-02-20
>
feihong04:02:35

i created a new luminus project using +swagger. this is what my swagger spec looks like:

{:swagger {:ui "/swagger-ui"
             :spec "/swagger.json"
             :data {:basePath (:app-context env)
                        :info {:version "1.0.0"
                        :title "Sample API"
                        :description "Sample Services"}}}}
the problem is that (:app-context env), which comes from [quickstart.config :refer [env]], seems to be nil when the routes are set, so :basePath doesn’t receive the value that it should. is there a better way to set this up while preserving DRY?

timo13:02:47

I think I am having a similar issue. Do you have a solution?

feihong15:02:50

yes, i did come up with a solution, but perhaps it was a very good one. See https://github.com/feihong/re-frame-quickstart/commit/bb90c259c381180206d8228a099d2e9e235c7564. Basically, i made a call to (mount/start #'my-app.config/env) before setting :basePath.

feihong15:02:04

*perhaps not a very good one

feihong15:02:34

by my understanding, mount is supposed to know what order to start the defstates, but perhaps that doesn’t work in my case because there is no call to defstate in quickstart.routes.services.

timo15:02:05

Thanks, I thought about this as well. Not beautiful but if it works....

feihong16:02:49

unless someone tells me otherwise, i think the best thing to do would be to put a call to (mount/start #'quickstart.config/env) inside -main to ensure that (:app-context env) has a value when setting up service routes

yogthos16:02:54

@lepistane your connection between the server and the client should be going over TLS, and if you can't trust TLS then there's really nothing you can do to make it secure

yogthos16:02:47

ultimately, the client has to pass the credentials to the server, and if those can be observed and replayed by a third party there's no way to make that secure at that point

yogthos16:02:07

so best practice is making sure everything goes over HTTPS, and you're using CSRF

yogthos16:02:21

@feihong.hsu the proper approach would be to use defstate for the swagger routes

yogthos16:02:08

using defstate ensures that resources are started in proper order and your env will be loaded before the swagger routes

feihong17:02:33

@yogthos works perfectly! thx