How to create REST API in noir to receive list of ids?

644 views Asked by At

How I can have an API which can be called as http://our.api.com/product/<id1>,<id2> and receive the list of ids using webnoir ?

1

There are 1 answers

5
zmila On BEST ANSWER
(defpage product-view "/product/:ids" {:keys [ids]}
  (str (into [] (map #(Integer/parseInt %) (.split ids "-"))))
  )

here one parameter (ids) is passed to split by "-", and then each element is parsed as int for url http://our.api.com/product/11-222-3 the output will be [11 222 3]

you can select other separator then "-", but ,.; are not working (i have no time to figure what it is: restriction of ring or smth else)