Fork me on GitHub
#kekkonen
<
2016-08-26
>
ikitommi10:08:25

@vijayakkineni by design, Kekkonen doesn’t make it easy to split parameters into multiple parameter-sets. Having separate query-, header- & body-params makes it harder to use the handler via other channels. We are using Sente & websockets in few projects, where the data is just passed in as a tuple [:search {:type :similar, :linked? false, :origin {}}].

ikitommi10:08:41

But, it’s doable if you want to do that, at least two ways:

ikitommi10:08:09

1) read the :request directly in the handler:

(defnk ^:command search
  "Searches a patient"
  {:responses {:default {:schema types/PatientSearchResponse}}}
  [[:request 
    [:query-params type :- (:type PatientSearchRequest}, linked :- (:linked PatientSearchRequest)]]
    [:data origin :- (:origin PatientSearchRequest)]]
  (success data))

ikitommi10:08:49

2) create a new handler-type into ring-handler. You can set how the request-paramters are mapped into data. See example on the CQRS-api: https://github.com/metosin/kekkonen/blob/master/src/kekkonen/cqrs.clj#L50-L59

ikitommi10:08:28

the CQRS-style is just an example, we are using a modified version of that (will push that into core at some point).

ikitommi10:08:49

so, you can define a modified commmand like this:

ikitommi10:08:52

{:command {:methods #{:post}
           :parameters {[:data] [:request :body-params]
                        [:query] [:request :query-params]}}}

ikitommi10:08:54

hope this helps.

vijayakkineni12:08:44

@ikitommi: thank you that helps.