luminus-framework / luminus-template

a template project for the Luminus framework
http://www.luminusweb.net/
MIT License
645 stars 147 forks source link

when request body is xml, body is nill #563

Closed vinurs closed 2 years ago

vinurs commented 2 years ago

i use

lein new luminus app +undertow +postgres +swagger +auth +auth-jwe

create a service, and add the code below

["/test-xml"
    {:post {:swagger {:consumes ["application/xml"]}
            :summary "test xml"
            :parameters {:body any?}
            :responses {200 {:body any?}}
            :handler (fn [{{{:keys [] :as body} :body
                            {:keys [] :as query} :query
                            :as parameters} :parameters
                           {:keys [] :as headers} :headers
                           {:keys [] :as identity} :identity
                           :as all}]
                       (log/info body)
                       )}}]

then, send a request like this

图片

but the (log/info body) is nil

vinurs commented 2 years ago

https://clojurians.slack.com/archives/C7YF1SBT3/p1591340938060100

图片

we can use (slurp (:body request)) to get the body and parse it using xml lib