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

Unable to find out how to read form parameters in a POST in Compojure

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Am trying compojure for the first time, and I hit a wall. Am unable to extract form parameters from the request. Have been through the documentation and the first page of google search.
Still not able to figure out how this works. Can someone point me to a working code sample online , or explain how this works ?
 
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
Compojure is a pretty nice little library. What have you got so far? What exactly isn't working?
 
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
I have POST working with my route defined as:
Which responds to POST requests and reads the value of a parameter named "name". Testing with curl produces:


Is that something similar to what you have?
 
karthik raghunathan
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim,

Thanks for the prompt reply.
By employing a good mix of head-banging and bouncing around varied documentation(s), last night , I was able to get this working.
The mistake was fundamental.
I was trying both and

I was firing requests from Postman, and experimented with application/x-www-form-urlencoded and octet-stream for Content-Type.  
Nothing seemed to work, so I threw away everything and started again from scratch.

This time, I used instead of the that I was using before I was too cool for templates.
Then one user on #clojure gave me this link : http://stackoverflow.com/questions/3488353/whats-the-big-idea-behind-compojure-routes   from which
I gathered  I was not using -wrap-params or wrap-defaults , whatever the latest manifestation was. Once I added that,  I started getting an "Invalid csrf" error.
Then I stumbled upon one page on "Professional Clojure" which guided me to change the require statement to :

and this finally fixed it.

Coming from Java, there're a lot of walls I keep hitting for getting anything to work , and too many versions of documentation AND implementations ,
but once there, what is amazing is the (lack of ) lines of code actually required .

I have some follow on questions :
1) csrf tokens - what is the standard way to create these ?
2) is there an equivalent of "devise" for clojure ? What do we use for authentication - oauth and otherwise ?
3) is there ORM like Hibernate ? Since there are no objects in clojure, wouldn't JDBC do ? or is that not cool ?

Thanks !
Karthik


 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic