                      slicedef (get-in metadata [:slices slice])
                      query (params->Query (:params request) slicedef)
                      query (query/execute dataset (:table slicedef) query)
-                     base-href (:uri request)
-                     href (url-like (if-let [query-string (:query-string request)]
-                                      (str base-href "?" query-string)
-                                      base-href))
-                     result (:result query)
-                     clauses (map (comp keyword :key) views/clauses)
-                     page (:page query)
-                     resource (-> (hal/new-resource href)
-                                  (hal/add-link :rel "up" :href (urls/dataset-path dataset))
-                                  (hal/add-link :rel "query"
-                                                :href
-                                                (str base-href "?"
-                                                     (str/join "&"
-                                                      (map
-                                                       (comp #(str "$" % "={?" % "}") name)
-                                                       clauses)))
-                                                :templated true)
-                                  (hal/add-properties {:dataset dataset :slice (name slice)})
-                                  (hal/add-properties {:size (:size result) :total (:total result)})
-                                  (hal/add-property :page page)
-                                  (hal/add-property :query (select-keys query clauses))
-                                  (hal/add-property :dimensions (:dimensions query))
-                                  (hal/add-property :results (:data result)))
-                     view-map {:base-href base-href
+                     resource (slice-resource slice request query)
+                     view-map {:base-href (:uri request)
                                :metadata metadata
                                :slicedef slicedef
                                :headers headers

                     resource (reduce #(hal/add-resource %1 "slice" %2) resource embedded)]
                 (views/dataset (:media-type representation) resource))))

(defresource
  ^{:doc "Resource for an individual slice."}
  slice

(defresource
  ^{:doc "Resource for an individual dataset."}
  dataset
  :available-media-types ["text/html" "application/json" "application/xml"]
  :method-allowed? (request-method-in :get)
  :exists? (fn [{:keys [request]}]
             (let [dataset (get-in request [:params :dataset])
