Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't access whole form parameter list during handler execution #442

Open
Invertisment opened this issue Apr 14, 2020 · 0 comments
Open

Comments

@Invertisment
Copy link

Invertisment commented Apr 14, 2020

Library Version(s)

[org.clojure/clojure "1.10.1"]
[metosin/compojure-api "1.1.13"]
[ring/ring-core "1.8.0"]
[metosin/muuntaja "0.6.6"]
[metosin/ring-http-response "0.9.1"]

Problem

I want to get all form/body parameters (or body string) in my request. I've tested out many ways and I can't find any way to do it.
I added many details in this SO question: https://stackoverflow.com/questions/61206840/how-do-i-obtain-all-of-plain-post-form-parameters-in-compojure-api-sweet

I've registered an answer there first because I thought it's a problem of not being familiar with ring and compojure-api. But there is not so much people traffic. If you're interested in more details then read the SO question too.

Code (SO version contains longer one):

(POST "/api/:variable" req
       (println
                (:form-params req) ;; {}
                (:body-params req) ;; {}
                (:params req)      ;; {:variable asd}
                (:body req))       ;; #object[org.eclipse.jetty.server.HttpInputOverHTTP 0x32205a75 HttpInputOverHTTP@32205a75[c=0,q=0,[0]=null,s=EOF]]
       (ok))

As I understand the (:body req) is already consumed somewhere but I don't know where and I'd like to get the output of it.
I've read how restructuring works in Compojure api method but it only supports known keys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant