Win a copy of Head First Android this week in the Android forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

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

 
Marshal
Posts: 5119
319
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: 357
21
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
Marshal
Posts: 5119
319
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: 357
21
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
Marshal
Posts: 5119
319
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic