This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-07-09
Channels
- # beginners (20)
- # boot (4)
- # cider (2)
- # cljs-dev (25)
- # clojure (45)
- # clojure-dev (1)
- # clojure-greece (5)
- # clojure-italy (20)
- # clojure-nl (12)
- # clojure-russia (11)
- # clojure-uk (256)
- # clojurescript (176)
- # data-science (33)
- # datomic (47)
- # docs (1)
- # duct (13)
- # fulcro (54)
- # graphql (24)
- # hoplon (3)
- # jobs (1)
- # leiningen (32)
- # luminus (3)
- # midje (1)
- # mount (2)
- # off-topic (3)
- # onyx (5)
- # overtone (1)
- # parinfer (12)
- # pedestal (4)
- # re-frame (60)
- # reagent (11)
- # reitit (3)
- # ring-swagger (21)
- # rum (1)
- # shadow-cljs (16)
- # spacemacs (23)
- # tools-deps (19)
- # vim (79)
Hi, I'm using duct to serve a fulcro webapp and I want to alias "/" as "/index.html" so it's served as a static route. I've tried using the following configuration keys:
:duct.middleware.web/route-aliases {"/" "/index.html"}
:duct.core/handler {:middleware [#ig/ref :duct.middleware.web/route-aliases]}
but not having any luck getting http :3000
to serve the same as http :3000/index.html
I can’t see anything obviously wrong with that. What does (pprint (:duct.core/handler config))
look like?
{:middleware [#ig/ref :duct.middleware.web/route-aliases
#ig/ref :duct.middleware.web/not-found
#ig/ref :duct.middleware.web/webjars
#ig/ref :duct.middleware.web/defaults
#ig/ref :duct.middleware.web/log-requests
#ig/ref :duct.middleware.web/log-errors
#ig/ref :duct.middleware.web/stacktrace],
:router #ig/ref :duct/router}
is the outputand
(pprint (:duct.middleware.web/route-aliases config))
is {"/" "/index.html"}
@weavejesterHm. I don’t see anything wrong with that, either…
What happens when you go to “/”?
Oh, actually, I do see the problem.
If the index page is static, then it will be served by wrap-resource
in the defaults middleware before the route-aliases are reached.
So:
{:middleware [#ig/ref :duct.middleware.web/not-found
#ig/ref :duct.middleware.web/webjars
#ig/ref :duct.middleware.web/defaults
#ig/ref :duct.middleware.web/route-aliases]}
By putting the references in directly, you can explicitly specify the order.
@weavejester Thanks! just tried that and it works perfectly 🙂
No problem! I’ve been thinking about a more sophisticated way of ordering middleware, but it’s always a tradeoff.