This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-20
Channels
- # 100-days-of-code (2)
- # aleph (53)
- # architecture (2)
- # aws (3)
- # beginners (230)
- # boot (15)
- # calva (3)
- # cider (19)
- # cljs-dev (1)
- # clojure (139)
- # clojure-conj (3)
- # clojure-italy (47)
- # clojure-nl (19)
- # clojure-spec (26)
- # clojure-uk (98)
- # clojurescript (152)
- # clojutre (4)
- # core-async (22)
- # cursive (5)
- # datomic (48)
- # emacs (11)
- # events (1)
- # figwheel-main (219)
- # fulcro (15)
- # instaparse (3)
- # jobs (4)
- # jobs-rus (1)
- # leiningen (30)
- # luminus (8)
- # off-topic (67)
- # onyx (5)
- # pedestal (16)
- # re-frame (1)
- # reagent (4)
- # reitit (31)
- # ring (8)
- # ring-swagger (3)
- # shadow-cljs (115)
- # specter (4)
- # videos (1)
- # vim (20)
- # yada (15)
Could someone point me in the right direction with getting started with reitit and immutant? From the example it seemed like this would work. https://gist.github.com/titaniumbrella/eb99887315775e3f607219cb3e50b838
@decim, reitit-http
uses the interceptor-model and requires an interceptor executor to work. You can use pedestal or Sieppari, here’s with the latter one:
(ns user
(:require [reitit.http :as http]
[reitit.interceptor.sieppari :as sieppari]))
(def app
(http/ring-handler
(http/router
[["/carbon" {:get {:handler (fn [_] {:status 200 :body "Carbonish 2.0"})}}]])
{:executor sieppari/executor}))
;;-- Start Immutant web server -----------------------------
(defn start []
"Start web server"
(immutant.web/run #'app {:port 3333})
(println "SERVER: STARTED!"))
(defn stop []
"Stop web server"
(immutant.web/stop)
(println "SERVER: STOPPED!"))
the default web/run
calls the handler synchronously, so it’s blocking despite you using manifold, core.async or some other. I have a Immutant3.0 branch somewhere, which has the :async?
option like jetty does.
@ikitommi hmm ahh i see. i’m afraid to take on pedestal as i’m fairly new but i do have a friend that uses it. what if i went with reitit.ring instead?
I have many PRs on the web servers & ring to get built-in support for NIO & async, might take some time to get all in. Someone should make a good abstraction over web servers, so that one could change easily between aleph, immutant, jetty etc. e.g. common way to go async, maybe websockets too. Pedestal has something like this, but it’s kinda separate island (of everything)
hmm i see. That sort of confused me. Both reitit and pedestal are used for routing so what do you get from combining the two?
pedestal + reitit is just a example, mainly to show that it can be done and for those that have already invested in pedestal and would add things like swagger & coercion into their apps.
reitit-ring is for ring-users, reitit-http is bit rough (sieppari has version 0.0.0-alpha5 out), but I think it’s a stack for the future. Good thing is that the route syntax is same for all, should be possible to start with one and port to another later.
we are currently using reitit-ring in the projects (and compojure-api and others for many older ones).
I see. so say i switched over to ring/ring-handler… i would think that that would just work as is, no? https://gist.github.com/titaniumbrella/c4b85d952bf015aec0f9cbe6fa7ce2bf
and i appreciate this…now i’m at least in the ballpark. I had no idea what I was truly looking at as far as choosing ‘http’ over ring
the app
should be:
(def app
(ring/ring-handler
(ring/router
[(routes)])
(ring/create-default-handler)))
or with values:
(def routes
["/carbon" {:get home-page}])
(def app
(ring/ring-handler
(ring/router
routes)
(ring/create-default-handler)))
you can nest routes in extra vectors if you like, the are flattened by the route compiler.
hmm really not sure. i just restarted my repl and i’m experiencing the same thing. Here’s my project.clj. I assume we’re using the same versioning or similar enough. https://gist.github.com/titaniumbrella/ad9409605d5cc8a7c21ddea93dec1723
@decim for me the main thing about pedestal is that it claims it’s production-ready, with logging already setup, some common-sense security middleware/interceptors already setup for you, and of course the interceptor chain which is a very very powerful concept. I haven’t looked closely to anything else in pure ring land though so I may be missing something.
@orestis yeah i wouldn’t mind giving pedestal a go but if i’m already having trouble with immutant it’s most likely going to be more of a set back for now