Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
metosin/reitit-pedestal {:mvn/version "0.7.2"}
metosin/reitit-swagger {:mvn/version "0.7.2"}
metosin/reitit-swagger-ui {:mvn/version "0.7.2"}
ring/ring-codec {:mvn/version "1.2.0"}
migratus/migratus {:mvn/version "1.6.3"}
org.slf4j/slf4j-simple {:mvn/version "2.0.17"}
prismatic/schema {:mvn/version "1.4.1"}}
Expand Down
10 changes: 9 additions & 1 deletion src/parenthesin/helpers/state_flow/server/pedestal.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
(:require [cheshire.core :as json]
[clojure.string :as string]
[io.pedestal.test :as pt]
[ring.util.codec :as codec]
[state-flow.api :as state-flow.api]
[state-flow.core :as state-flow :refer [flow]]))

(defn- do-request [service-fn verb route body headers]
(let [headers-with-default (merge {"Content-Type" "application/json"} headers)
encoded-body (json/encode body)]
content-type (get headers-with-default "Content-Type")
encoded-body (case content-type
"application/json" (json/encode body)
"application/x-www-form-urlencoded" (codec/form-encode body)
body)]
(pt/response-for service-fn verb route :headers headers-with-default :body encoded-body)))

(defn- parsed-response
Expand All @@ -17,6 +22,9 @@
request))

(defn request!
"Flow that make http request using `:io.pedestal.http/service-fn`, not a fully
featured http client, currently only supports content type `application/json`
and `application/x-www-form-urlencoded`."
[{:keys [method uri body headers]}]
(flow "makes http request"
[service-fn (state-flow.api/get-state (comp :io.pedestal.http/service-fn :webserver :webserver))]
Expand Down
Loading