Skip to content

Instantly share code, notes, and snippets.

@dustingetz
Last active November 23, 2015 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustingetz/3ae4ff6eb2679491dccf to your computer and use it in GitHub Desktop.
Save dustingetz/3ae4ff6eb2679491dccf to your computer and use it in GitHub Desktop.

Here is the root of a hypercrud rest api:

{:hypercrud
 {:href #<URI /api?tx=13194139534333>,
  :rel :index-get,
  :links
  {:enums/region {:href #<URI /api/enums/region?tx=13194139534333>},
   :neighborhoods {:href #<URI /api/neighborhoods?tx=13194139534333>},
   :enums/community.orgtype {:href #<URI /api/enums/community.orgtype?tx=13194139534333>},
   :communities {:href #<URI /api/communities?tx=13194139534333>},
   :districts {:href #<URI /api/districts?tx=13194139534333>},
   :enums/community.type {:href #<URI /api/enums/community.type?tx=13194139534333>}},
  :type :collection,
  :data {},
  :queries [],
  :template nil},
 :cache nil}

Navigate into {:href #<URI /api/communities?tx=13194139534333>}

{:hypercrud
 {:href #<URI /api/communities?tx=13194139534333>,
  :rel :communities,
  :links [],
  :type :collection,
  :data
  {:communities-item/17592186045487
   {:href #<URI /api/communities/17592186045487?tx=13194139534333>, :rel :communities-item/17592186045487},
   :communities-item/17592186045562
   {:href #<URI /api/communities/17592186045562?tx=13194139534333>, :rel :communities-item/17592186045562},
   :communities-item/17592186045598
   {:href #<URI /api/communities/17592186045598?tx=13194139534333>, :rel :communities-item/17592186045598},
   ;; ... snip ...
   :communities-item/17592186045498
   {:href #<URI /api/communities/17592186045498?tx=13194139534333>, :rel :communities-item/17592186045498}},
  :queries [],
  :template
  {:data
   [{:datatype :string, :name :community/name, :prompt "Name", :set false}
    {:datatype :string, :name :community/url, :prompt "Url", :set false}
    {:datatype :ref,
     :name :community/neighborhood,
     :prompt "Neighborhood",
     :options {:rel :neighborhoods, :href #<URI /api/neighborhoods?tx=13194139534333>, :label-prop :neighborhood/name},
     :set false}
    {:datatype :string, :name :community/category, :prompt "Category", :set true}
    {:datatype :ref,
     :name :community/orgtype,
     :prompt "Org type",
     :options {:rel :enums/community.orgtype, :href #<URI /api/enums/community.orgtype?tx=13194139534333>, :label-prop :db/ident},
     :set false}
    {:datatype :ref,
     :name :community/type,
     :prompt "Type",
     :options {:rel :enums/community.type, :href #<URI /api/enums/community.type?tx=13194139534333>, :label-prop :db/ident},
     :set true}]}},
 :cache nil}

Navigate into {:href #<URI /api/communities/17592186045487?tx=13194139534333>}:

{:hypercrud
 {:href #<URI /api/communities/17592186045487?tx=13194139534333>,
  :rel :communities-item/17592186045487,
  :type :object,
  :data
  {:community/name "Capitol Hill Community Council",
   :community/url "http://chcc.wikidot.com/",
   :community/neighborhood {:href #<URI /api/neighborhoods/17592186045439?tx=13194139534333>, :rel :neighborhoods-item/17592186045439},
   :community/category #{"news" "community council" "events"},
   :community/orgtype
   {:href #<URI /api/enums/community.orgtype/17592186045417?tx=13194139534333>, :rel :community.orgtype-item/17592186045417},
   :community/type #{{:href #<URI /api/enums/community.type/17592186045426?tx=13194139534333>, :rel :community.type-item/17592186045426}}},
  :links [],
  :template
  {:data
   [{:datatype :string, :name :community/name, :prompt "Name", :set false}
    {:datatype :string, :name :community/url, :prompt "Url", :set false}
    {:datatype :ref,
     :name :community/neighborhood,
     :prompt "Neighborhood",
     :options {:rel :neighborhoods, :href #<URI /api/neighborhoods?tx=13194139534333>, :label-prop :neighborhood/name},
     :set false}
    {:datatype :string, :name :community/category, :prompt "Category", :set true}
    {:datatype :ref,
     :name :community/orgtype,
     :prompt "Org type",
     :options {:rel :enums/community.orgtype, :href #<URI /api/enums/community.orgtype?tx=13194139534333>, :label-prop :db/ident},
     :set false}
    {:datatype :ref,
     :name :community/type,
     :prompt "Type",
     :options {:rel :enums/community.type, :href #<URI /api/enums/community.type?tx=13194139534333>, :label-prop :db/ident},
     :set true}]}},
 :cache nil}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment