This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-16
Channels
- # aleph (2)
- # announcements (1)
- # aws (2)
- # babashka (5)
- # beginners (122)
- # boot-dev (1)
- # cider (3)
- # clara (7)
- # cljdoc (11)
- # clojure (161)
- # clojure-dev (45)
- # clojure-europe (8)
- # clojure-france (1)
- # clojure-india (1)
- # clojure-italy (3)
- # clojure-nl (11)
- # clojure-uk (34)
- # clojurebridge (2)
- # clojurescript (13)
- # cryogen (10)
- # cursive (13)
- # datomic (25)
- # emacs (8)
- # fulcro (76)
- # graalvm (2)
- # jackdaw (5)
- # jobs-discuss (2)
- # juxt (13)
- # off-topic (13)
- # pathom (5)
- # pedestal (7)
- # quil (2)
- # reitit (9)
- # remote-jobs (4)
- # schema (1)
- # shadow-cljs (33)
- # spacemacs (8)
- # sql (9)
- # vim (2)
- # vrac (2)
hello everyone! When I use duct+pedestal+reitit, i get an error.
route-spec error
(s/def ::x decimal?)
(s/def ::y decimal?)
(s/def ::total int?)
(s/def ::math-request (s/keys :req-un [::x ::y]))
(s/def ::math-response (s/keys :req-un [::total]))
(defn interceptor [number]
{:enter (fn [ctx] (update-in ctx [:request :number] (fnil + 0) number))})
(defmethod ig/init-key :yzcx/routes
[_ _]
["/plus"
{:get {;:summary "plus with spec query parameters"
:parameters {:query ::math-request}
; :responses {200 {:body ::math-response}}
:handler (fn [{{{:keys [x y]} :query} :parameters}]
{:status 200
:body {:total (+ x y)}})
:interceptors [(interceptor 1)]
}
:post {;:summary "plus with spec body parameters"
:parameters {:body ::math-request}
;:responses {200 {:body ::math-response}}
:handler (fn [{{{:keys [x y]} :body} :parameters}]
{:status 200
:body {:total (+ x y)}})
:interceptors [(interceptor 1)]
}}]
)
Anyone know how to fix this? Thanks
@zhoumin79 that's an pedestal error, can't help there. Some missconfig at the border. The reitit-pedestal example should work, I would start to compare with that
:duct.server/pedestal
{:service #:io.pedestal.http {:router #ig/ref :duct.router/reitit
:host #duct/env "SERVER_HOST"
:port #duct/env ["SERVER_PORT" Int :or 3000]}}
:duct.router/reitit
{:routes #ig/ref :yzcx/routes
}
:yzcx/routes {}
this is my relate config from edn
(def common-interceptors
[;; query-params & form-params
(parameters/parameters-interceptor)
;; content-negotiation
(muuntaja/format-negotiate-interceptor)
;; handle exceptions
;(exception/exception-interceptor)
;; encoding response body
(muuntaja/format-response-interceptor)
;; decoding request body
(muuntaja/format-request-interceptor)
;; coercing response bodys
(coercion/coerce-response-interceptor)
;; coercing request parameters
(coercion/coerce-request-interceptor)])
(defmethod ig/init-key :duct.router/reitit
[_ {:keys [routes]}]
(http/router
[routes]
{:data {:coercion reitit.coercion.spec/coercion
:interceptors common-interceptors}}))
@ikitommi Do you have any clue? Thanks.