This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-31
Channels
- # announcements (5)
- # babashka (105)
- # beginners (92)
- # calva (77)
- # cider (17)
- # cljdoc (8)
- # cljs-dev (8)
- # cljsrn (8)
- # clojure (272)
- # clojure-dev (25)
- # clojure-europe (5)
- # clojure-italy (6)
- # clojure-nl (7)
- # clojure-norway (3)
- # clojure-uk (108)
- # clojurescript (326)
- # code-reviews (4)
- # cursive (6)
- # datomic (37)
- # duct (5)
- # emacs (14)
- # fulcro (23)
- # graphql (1)
- # juxt (1)
- # kaocha (2)
- # leiningen (10)
- # malli (9)
- # music (1)
- # nrepl (12)
- # pathom (21)
- # pedestal (2)
- # planck (4)
- # quil (3)
- # reitit (29)
- # rewrite-clj (10)
- # shadow-cljs (82)
- # spacemacs (29)
- # sql (6)
- # tools-deps (19)
Is there a way to apply a content-type for all returned data, i.e., if I know that I'll always be returning JSON, to set that as applicable for every response? At the moment, I'm setting it within the response map that I return, i.e.,
@U11EL3P9U You could check this sample with mostly everything on: https://github.com/metosin/reitit/tree/master/examples/ring-swagger
However, if I don't require (or need) swagger for my use-case, it's a bit overkill to depend upon it
swagger-data is inferred from routes, parameter and response definitions. Just don’t mount the swagger-spec & swagger-ui endpoints and it’s gone 🙂
["/starships/:id" {:get get-starship-by-id
:produces #{"application/json"}
:parameters {:path {:id s/Int}}}]]
if you have Muuntaja middleware mounted, any response with a collection body and without Content-Type header is encoded into json/edn/transit, depending on what the client requested. It defaults to json (e.g. client is ok with anything)
Hi there a way to abort navigation for the front end stuff? on-navigate gets called after it’s happened?
@ikitommi thanks for the above tip, I can confirm that if the response body is a collection and if the muuntaja
middleware is being used and if no content-type
header is being set and if the client requests accept: application/json
then yes, the response does come back as content-type: application/json