Questions tagged [liberator]

Liberator is a Clojure library that helps expose data as REST resources while automatically complying with all the relevant requirements of HTTP specification (RFC-2616).

Liberator is a Clojure library that helps expose data as REST resources while automatically complying with all the relevant requirements of HTTP specification (RFC-2616).

38 questions
8
votes
2 answers

How to implement user authentication using clojure-liberator?

I'm not really understanding https://github.com/clojure-liberator/liberator and the list of decision points that it provides to the developer. How would one implement a basic auth/auth service using/alongside/on-top-of the library?
zcaudate
  • 13,998
  • 7
  • 64
  • 124
7
votes
1 answer

Clojure web frameworks for responsive apps

I have recently inherited a non-finished web app written in Clojure, based on compojure and hiccup basically. It's a bad attempt to model some sort of MVC with OO style not in the FP style as seen here . So I bet to re-start the project almost from…
Jaime Agudo
  • 8,076
  • 4
  • 30
  • 35
6
votes
3 answers

How to return json data from post! handler in clojure liberator?

How to return json-data with Clojure Liberator? This code doesn't work: (defresource poster [] :allowed-methods [:post :options] :available-media-types ["application/json"] :post! (fn [ctx] (println "posting...")) …
Curiosity
  • 651
  • 1
  • 5
  • 12
6
votes
1 answer

clojure liberator - returning json from a put request

I am struggling to return JSON from a put! request: My code looks like this: (defn body-as-string [ctx] (if-let [body (get-in ctx [:request :body])] (condp instance? body java.lang.String body (slurp (io/reader body))))) (defn…
dagda1
  • 26,856
  • 59
  • 237
  • 450
4
votes
0 answers

JSON representation problem with liberator

I'm trying to define a really simple resource with Liberator. To start off a minimal example, I wrote an handler like this: (resource :handle-ok {:hello "world"}) But despite clearly passing a value (that isn't nil) I got the following…
MasterMastic
  • 20,711
  • 12
  • 68
  • 90
3
votes
3 answers

Using Prismatic/schema for form validation with Liberator

Is Prismatic/schema a good fit for form validation? I have never designed a form validation lib before, but I imagine it outputting something like this instead of throwing exceptions on s/validate: {::errors {:name [{:missing "Required field."} …
Petrus Theron
  • 27,855
  • 36
  • 153
  • 287
3
votes
1 answer

Outputting html for liberator's handle-unauthorized

I am using liberator with ring/compojure and would like to handle authorization using the liberator defresource macros. I can easily get handle-ok to output html that is recognized by the browser, but handle-unauthorized will have the html output…
MattoxBeckman
  • 3,682
  • 2
  • 20
  • 16
3
votes
1 answer

Returning a Location header in a 201 Created response in Liberator

I'm trying to implement a collection resource with Liberator where a POST request to the collection URL (e.g. /posts) would create a new blog post item. That's working fine. What is not working is responding to the POST request with a 201 Created…
liwp
  • 6,746
  • 1
  • 27
  • 39
2
votes
1 answer

How to redirect get methods with Liberator in Clojure?

I have an endpoint called /account which provides user info(returns html). When unauthorised user tries to access this endpoint I need to be able to redirect to login page but in Liberator I found post-redirect so far and it is just for post…
Ertuğrul Çetin
  • 5,131
  • 5
  • 37
  • 76
2
votes
1 answer

Post Does Not Return 200 OK in Liberator Clojure

I want my POST resource to return 200 OK so I can use :handle-ok but resource returns 201 Created. I use my resource for the login operation. :handle-ok does not work! Here is the example code: (POST "/login" [] (resource…
Ertuğrul Çetin
  • 5,131
  • 5
  • 37
  • 76
2
votes
1 answer

Multiple clojure-liberator decisions reads request body

I have one defresource, that is supposed to take POST-requests, validate request body in :malformed-decision, save the body to database in :post!-decision and return the saved body in :handle-created. (defn parse-project [context] (json/read-str …
samu
  • 1,936
  • 4
  • 22
  • 26
2
votes
3 answers

Getting a clojure map with keywords from a POST using Liberator

I'm using Liberator, and am having a hard time getting my POSTed data into a map using with keywords as the keys. Here is my resource, with a few printlines for testing: (defresource finish_validation :allowed-methods [:post] …
pickwick
  • 3,134
  • 22
  • 30
2
votes
2 answers

I use clojure for creating REST API. How to generate REST documentation automatically?

I'm writing clojure rest service (with ring, compojure and liberator) and would like to automatically generate API documentation for all my REST API. It's very tedious to generate it manually. Is there any way to use annotations or something like…
Curiosity
  • 651
  • 1
  • 5
  • 12
2
votes
2 answers

Converting compojure noir to Liberator

I'm fairly new to clojure/compojure, but really love it. Naturally, started my exploration with Noir stack. Have written a POC app. Then, discovered Liberator -- makes a whole lot of sense. Just wondering, if anybody has ever migrated Noir…
dmitryame
  • 478
  • 4
  • 19
2
votes
2 answers

Post Request with clojure liberator

I am using clojure liberator to expose my services as REST service,I have a POST request, Below is the code, I could do the process on calling the service as POST, but I want to send back the event id as response of the POST, Can anyone…
user1249655
  • 477
  • 1
  • 6
  • 17
1
2 3