Search code examples
restclojurenoir

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


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 ?


Solution

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