This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-26
Channels
- # aleph (2)
- # beginners (119)
- # boot (18)
- # cider (19)
- # cljs-dev (46)
- # cljsjs (1)
- # cljsrn (30)
- # clojure (101)
- # clojure-dusseldorf (12)
- # clojure-finland (1)
- # clojure-greece (7)
- # clojure-india (2)
- # clojure-italy (6)
- # clojure-poland (4)
- # clojure-russia (120)
- # clojure-sg (3)
- # clojure-spec (147)
- # clojure-uk (75)
- # clojurescript (86)
- # cursive (4)
- # datomic (50)
- # docker (1)
- # emacs (4)
- # juxt (51)
- # leiningen (16)
- # liberator (1)
- # luminus (1)
- # lumo (116)
- # mount (2)
- # off-topic (2)
- # onyx (38)
- # pedestal (4)
- # protorepl (2)
- # re-frame (44)
- # reagent (8)
- # ring-swagger (16)
- # schema (5)
- # specter (16)
- # test-check (226)
@jonpither waiting for your comments…
@viebel have a look at https://github.com/juxt/mach/blob/master/examples/extensions/Machfile.edn
It works like a charm @jonpither @dominicm 👏
@viebel I'll have to use this myself for our training machfile. Gotta oss that thing 🙂
Definitely
Hi there. I’m using bidi on the frontend (great combo!), and trying to encode a set of routes in a way which would make it easier for me to do i18n.
I have a map of routes like {"" :home "about/" :about}
etc. and, in front of that, there’s either a [/ :lang /]
, or just a “/”, which would mean the default language.
So, I tried:
(def app-routes
["/" [["" common-routes-map]
[[[keyword :lang] "/"] common-routes-map]
[true :404]]])
And it works great, the lang is captured in a keyword, and the shared routes show up on the handlers, but in generating routes the :lang
-less route is taking precedence wether the :lang
keyword is present or not.. I’ve been trying quite a few different workarounds but most feel too clever.
Is there a better way to “encode” the route along the lines of what I want to achieve?@minikomi if you move the [[keyword :lang] "/" …
before the ["" common-routes…]
does that solve your problem?
Yep got it! Makes sense. I wonder if there’s a way to restrict the value of the keyword? If not i can just check within the app on navigation.
I'm not certain off the top of my head, but you have 2 options:
- Use a regex and use a middleware to coerce it to a keyword
- Look at how the regex/fn validators are implemented within bidi, most of bidi is extensible, you may be able to just drop your own function in there & return false
when it doesn't match.
Yeah, I went down route one for a little while but ended up having too much string / keyword juggling for my liking.
Does a middleware like this not solve it:
(defn coerce-lang
[handler]
(fn [req]
(handler (update-in req [:route-params :lang] keyword)))
Oops, just found out that having the [keyword :lang]
version first means that not having a :lang
keyword throws an exception.
The other way around it is use the original order then a fn like:
(defn to [handler &{:keys [lang]
:as params}]
(let [url (b/unmatch-pair i18n-routes {:handler handler
:params (dissoc params :lang)})]
(if lang (str "/" (name lang) url)
url)))
A bit tricky, since I want to capture it if it exists, ignore it if it’s not there..
I'm not sure what bidi's rules are about duplicate handlers in a route structure tbh.
yeah, seems a bit sketchy but it makes for nice routes / logic throughout - can just check a :lang value to change some things but keep most of the structure of the app the same
@jonpither what is the best way to deploy a clojure web server (catacumba) to aws beanstalk?
Your article is quite old https://juxt.pro/blog/posts/beanstalk.html
May 2015
Is it still relevant?
@viebel we have a new approach, I literally 50% through the blog. I can take you through it if you want - it's a bit alpha tho
My customer requires beanstalk 😬
Is there a way to deploy the uberjar directly to beanstalk - without docker?
how do I setup docker on macos?
with brew?