Fork me on GitHub
#reitit
<
2020-01-17
>
ikitommi09:01:36

@zhoumin79 pedestal requires it’s own Router impl, it doesn’t understand the reitit Router. For this, there is some glue code to swap the routing intereceptor, see https://github.com/metosin/reitit/blob/master/examples/pedestal-swagger/src/example/server.clj#L118-L135

michael zhou09:01:12

(defmethod ig/init-key :duct.server/pedestal
  [_ {:keys [base-service
             service
             dev?]}]
  (let [config (duct/merge-configs
                base-service
                service)

        {router ::http/router
         port   ::http/port
         host   ::http/host} config]

    (println (str "\nCreating your " (when dev? "[DEV] ")
                  "server http://" (or host "localhost") ":" port))
    (cond-> config
      true (dissoc ::http/router)
      true http/default-interceptors
      true (pedestal/replace-last-interceptor
            (pedestal/routing-interceptor router))
      dev? http/dev-interceptors
      true http/create-server
      true http/start)))

michael zhou09:01:17

This is my code. Something wrong?

michael zhou11:01:59

Sorry to waste your time. It’s my bad

michael zhou11:01:41

@ikitommi I misspelled a config letter.

michael zhou11:01:10

Reitit is an awesome library.👍

💯 12
eoliphant16:01:00

Hi quick question, running reitit with pedestal, is there a suggested resolution for this? Perhaps a wrapper or something? > There is no common interceptor spec for Clojure and all default reitit interceptors (coercion, exceptions etc.) use the Sieppari interceptor model. It is mostly compatible with the Pedestal Interceptor model, only exception being that the `:error` handlers take just 1 arity (`context`) compared to Pedestal’s 2-arity (`context` and `exception`). > > Currently, out of the reitit default interceptors, there is only the `reitit.http.interceptors.exception/exception-interceptor` which has the `:error` defined.

dharrigan16:01:29

Is there an example of using clojure spec to validate a POST body?

ikitommi16:01:57

@eoliphant the reitit-pedestal module should take care of that.

ikitommi16:01:19

the docs are misleading?

eoliphant16:01:16

yeah to me at least, it seemed like an ‘issue’ lol

ikitommi16:01:57

please fix the docs if there is some old/bad info around

eoliphant16:01:02

maybe just some verbiage to indicate that the integration addresses it?

eoliphant16:01:13

sure, i can do that 🙂

ikitommi16:01:47

^:--- the latest swagger-ui (3.*) looks like that. I guess we could upgrade to that.

ikitommi16:01:27

seems to work ok. not a fan of the new ui, but it’s kinda de facto nowadays.

ikitommi16:01:22

pushed out 0.4.2, which has direct dependency to jackson-core, to fix this sadly-way-too-common maven issue: https://clojureverse.org/t/depending-on-the-right-versions-of-jackson-libraries/5111