Fork me on GitHub
#yada
<
2016-10-21
>
ericnormand18:10:35

good afternoon!

ericnormand18:10:58

I'm having some trouble with serving files using new-classpath-resource and the index-files option

ericnormand18:10:50

I'm wondering if my setup is messed up somehow

ericnormand18:10:59

(def routes
  (vhosts-model
    [[(str scheme "://" host)]
     ["/" {"dump" dump/handle-dump
           "" (yada/yada (new-classpath-resource "homepage" {:index-files ["index.html"]}))
           "dashboard" (yada/resource
                         {:id :dashboard
                          :produces {:media-type "text/html"
                                     :language "en"}
                          :response (fn [ctx]
                                      (dashboard-page))})
           "endpoints" (yada/resource
                         {:id :endpoints
                          :produces {:media-type "application/json"}
                          :methods {:post
                                    {:response
                                     (fn [ctx]
                                       (create-endpoint-request ctx))}}})
           ["endpoint/" :id]
           {"" (yada/resource
                 {:id :endpoint
                  :produces {:media-type "application/json"}
                  :methods {:post
                            {:consumes "multipart/form-data"
                             :parameters {:form {:file String}}
                             :response upload-request}}})
            ["/upload/" :upload-id] (yada/resource
                                     {:id :endpoint-upload
                                      :response nil})}}]]))

ericnormand18:10:09

There's my routes definition

ericnormand18:10:36

if I GET to localhost/index.html

ericnormand18:10:38

I get the page

ericnormand18:10:47

but if I GET to localhost/ I get a 405

ericnormand18:10:51

Ok, I figured it out by moving the / around

ericnormand18:10:30

now, another question: how do I name the homepage resource if it's in a new-classpath-resource?

ericnormand18:10:42

I'd like to give it an id so I can generate it