• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to perform a PUT or GET http request with Clojure?

 
Sheriff
Posts: 5555
326
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's say I have a http REST endpoint that accepts requests at localhost:8081/someurl. How would I perform a PUT request with parameters? How would I perform a GET request and obtain the response?

I found the slurp function which appears to cover the GET part of my question, but it doesn't help with doing the PUT.

Cheers, Tim
 
Rancher
Posts: 379
22
Mac OS X Monad Clojure Linux
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take a look at the clj-http library: https://github.com/dakrone/clj-http
 
Tim Cooke
Sheriff
Posts: 5555
326
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Sean, that was just the job.

I think this is part of the process of learning a new language, figuring out which libraries solve which problems.
 
Sean Corfield
Rancher
Posts: 379
22
Mac OS X Monad Clojure Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sometimes this site can be very helpful to locate libraries: https://crossclj.info

Or this one: http://www.clojure-toolbox.com

Both provide searchable lists of libraries. The latter is heavily curated and includes no searching of symbols; the former is automated and does include searching of symbols (searching for PUT brings up clj-http's put method, for example).
 
Tim Cooke
Sheriff
Posts: 5555
326
IntelliJ IDE Python Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bookmarked. Cow-worthy.
 
Skool. Stay in. Smartness. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic