kekkonen

ikitommi 2016-08-26T10:07:25.000007Z

@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 {}}].

ikitommi 2016-08-26T10:07:41.000008Z

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

ikitommi 2016-08-26T10:10:09.000009Z

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))

ikitommi 2016-08-26T10:11:49.000011Z

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

ikitommi 2016-08-26T10:13:28.000013Z

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

ikitommi 2016-08-26T10:13:49.000014Z

so, you can define a modified commmand like this:

ikitommi 2016-08-26T10:13:52.000015Z

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

ikitommi 2016-08-26T10:15:54.000016Z

hope this helps.

vijayakkineni 2016-08-26T12:05:44.000017Z

@ikitommi: thank you that helps.