This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-30
Channels
- # arachne (2)
- # beginners (8)
- # boot (19)
- # chestnut (2)
- # cider (1)
- # clara (1)
- # cljs-dev (31)
- # cljsrn (82)
- # clojure (163)
- # clojure-dusseldorf (7)
- # clojure-greece (1)
- # clojure-italy (4)
- # clojure-norway (3)
- # clojure-russia (24)
- # clojure-sg (5)
- # clojure-spec (6)
- # clojure-uk (42)
- # clojurescript (239)
- # core-async (4)
- # cursive (10)
- # data-science (18)
- # datascript (1)
- # datomic (110)
- # emacs (16)
- # euroclojure (1)
- # events (1)
- # figwheel (1)
- # hoplon (22)
- # keechma (2)
- # klipse (5)
- # lein-figwheel (3)
- # leiningen (7)
- # luminus (27)
- # melbourne (2)
- # mount (5)
- # nyc (7)
- # off-topic (35)
- # om (20)
- # onyx (49)
- # pedestal (41)
- # re-frame (31)
- # reagent (18)
- # remote-jobs (9)
- # ring (4)
- # ring-swagger (1)
- # spacemacs (6)
- # specter (6)
- # uncomplicate (3)
- # unrepl (9)
- # untangled (54)
- # yada (11)
The mylib.jar is actually oracles jdbc library… which they are a pita about not sharing via maven central… so I have to include out of band instructions for oracle users.
Hi @lellis. You might find https://github.com/pedestal/pedestal/tree/master/samples/jetty-web-sockets helpful.
You can use interceptors directly by calling http://pedestal.io/api/pedestal.interceptor/io.pedestal.interceptor.chain.html#var-execute with a context that you devise.
hello, is there some way to pass :allow-symlinks?
to the interceptor that already serves files from sources ::http/resource-path
?
Let me look into that @pedroteixeira.
thanks, really appreaciated - don't know yet where to look this up in the code
I'm not sure if I should create a new interceptor for this case
The interceptor supports it if you call io.pedestal.http.ring-middlewares/fast-resource
directly like this:
(middlewares/fast-resource "public" {:follow-symlinks? true})
So I suggest:
1. Leave ::http/resource
as nil in your service map.
2. Construct your own interceptor.
3. Call io.pedestal.http/default-interceptors
to construct the default interceptor stack. (This is normally done by create-server
)
4. Conj your interceptor into the defaults.
5. Start the server.
The parameter will always arrive as a string. But you could run it through clojure.tools.reader.edn/read-string
. If you wanted to do this in general, you could write an interceptor that parsed a set of query parameters (provided at construction time).
So,
... Obviously with attention to URL encode
I'm unsure if there was some default interceptor already.
for path-params
.
may be a thing? Then I read-string
on all values. It sounds like a good idea?
@mtnygard trying something along the lines, can you shed some light?
(http/create-server
(update
(http/default-interceptors service-map)
::http/interceptors
#(conj % (ring-middlewares/fast-resource "public" {:follow-symlinks? true}))))
I got the code from the guide on the side that used defrecord Pedestal
I think I got something wrong cause getting exception java.nio.file.StandardOpenOption cannot be cast to [Ljava.nio.file.OpenOption_ for any GET
I was looking for examples in ways to conj an interceptor into the default ones
yes - is it the preferred/easy option?
The exception says that someone is passing a single OpenOption where the API requires an array of them.
is there an easy way to use ring.util.response/resource-response
as the interceptor?
I see on the default interceptors, it is used instead of the fast-response
the ring version recently added it, I can see it on the source it now has one > https://github.com/ring-clojure/ring/blob/ecf06c142ee4195756f94b780c238f3a917b3b8d/ring-core/src/ring/util/response.clj#L318
Ah, ok. I can help in a while. Or in the meantime you could copy the function that builds the regular resource interceptor. (Right above fast-resource) and modify it to use the new middleware.
ok thanks for the help 👍 - I will try copying the resource/resource-request
to add the new arg, if there is a better way, let me know
it worked fine but had to copy to include support for the new arg
(defn resource-request
"If request matches a static resource, returns it in a response map.
Otherwise returns nil."
{:added "1.2"}
[request root-path & [{:keys [loader]}]]
(if (#{:head :get} (:request-method request))
(let [path (subs (codec/url-decode (request/path-info request)) 1)]
(-> (response/resource-response path {:root root-path :loader loader :allow-symlinks? true})
(head/head-response request)))))