Comments (5)
That's not in the spirit of how liberator works. Can you please give an example where you need this decision?
from liberator.
For example, I hava a resource named "User". And I want to use POST
method to create a user than use PUT
method to modify it. In additional, everyone can create user. But only user itself can modify it. So I have following code:
authorized? (fn [ctx] (case (get-in ctx [:request :request-method]) :post true :put (check-auth?)))
from liberator.
That is a good point! I like your idea of using a mapping of methods to decision functions. Another approach would by to provide a higher order function like
(decision? (by-method :get do-get :any:do-default))
with
(defn by-method [& kvs]
(fn [ctx]
(let [m (apply hash-map kvs)
method (get-in ctx [:request :request-method])]
(if-let [d (or (get m method) (get m :any))] (d ctx)))))
from liberator.
I think it's a good solution. Hoping for seeing it in version 1.0.
Maybe there can be a determination in by-method
for the situation that either method-key or :any
is not found?
from liberator.
Pull Request #23
from liberator.
Related Issues (20)
- Documentation (Decision Graph) broken HOT 1
- handle-exception raises exception HOT 1
- Reliance on javax.xml.ws HOT 6
- `combine` results in a lazy seq for lists and vectors HOT 1
- "GC overhead limit exceeded" caused by liberator.dev/logs HOT 2
- render-seq-generic strange behaviour for "text/html" "text/plain" "text/csv" HOT 1
- Blocking upgrade to java 9 & 10 HOT 3
- Default handler responses returned are invalid JSON [Was: JSON representation issue when resource does not exist] HOT 3
- javax.xml.ws on java 11 HOT 2
- A new home for the examples? HOT 2
- Disable passing response options HOT 1
- include defaults in decision graph HOT 1
- Boss, midje has a very good automated test method . HOT 2
- Support 409 for PATCH requests. HOT 7
- wrap-trace not working with component middleware stack. HOT 2
- Unable to set a cookie.
- How to extract the form data from a request in liberator? HOT 1
- post-redirect? not working or Preflight response is not successful
- Authorization vs Authentication HOT 5
- The decisions page should provide details about implementing decisions HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from liberator.