A simple Ring's middleware that generates RESTful links for resources from Bidi routes.
[ring.middleware.restful-bidi "0.2.0"]
(require '[ring.middleware.restful-bidi :refer [wrap-bidi-restful]])
(def restful-model
{:api/entry-point #{:api/users}})
(def routes
["" {"/" {:get :api/entry-point}
"/users" {:get :api/users}}])
(wrap-bidi-restful
app-handler
routes
"http://localhost:3000"
restful-model)
A response from :api/entry-point
"/"
resource will look like:
{
"_links": {
"self": {
"href": "http://localhost:3000/",
"type": "GET"
},
"users": {
"href": "http://localhost:3000/users",
"type": "GET"
}
}
A response from :api/users
"/users"
resource will look like:
{
"data": [{"username": "jdoe"}],
"_links": {
"self": {
"href": "http://localhost:3000/users",
"type": "GET"
}
}
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close