Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/fluree/server/handler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@
:coercion ^:replace history-coercer
:handler #'ledger/history})

(def info-endpoint
{:summary "Ledger status and statistics"
:handler #'ledger/info})

(def fallback-handler
(let [swagger-ui-handler (swagger-ui/create-swagger-ui-handler
{:path "/"
Expand Down Expand Up @@ -599,6 +603,8 @@
["/history" {:get history-endpoint
:post history-endpoint}]

["/info" {:get info-endpoint}]

["/ledger/{*ledger-path}" #'ledger-specific-handler]

["/subscribe"
Expand Down
5 changes: 5 additions & 0 deletions src/fluree/server/handlers/ledger.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@
(if (and (map? result) (:status result) (:result result))
{:status (:status result), :body (:result result)}
{:status 200, :body result})))

(defhandler info
[{:keys [fluree/conn fluree/opts] :as _req}]
(let [result (deref! (fluree/ledger-info conn (:ledger opts)))]
{:status 200 :body result}))
12 changes: 11 additions & 1 deletion test/fluree/server/integration/basic_query_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[fluree.db.util.json :as json]
[fluree.server.integration.test-system
:as test-system
:refer [api-post create-rand-ledger json-headers run-test-server]]))
:refer [api-get api-post create-rand-ledger json-headers run-test-server]]))

(use-fixtures :once run-test-server)

Expand Down Expand Up @@ -301,6 +301,16 @@
"https://ns.flur.ee/ledger#retract" []}]
(-> query-res :body (json/parse false))))))

(testing "info"
(let [info-res (api-get :info {:headers {"fluree-ledger" ledger-name}})]
(is (= 200 (:status info-res)))
(is (= ["address" "alias" "branch" "commit" "index" "namespace-codes" "stats" "t"]
(-> info-res :body (json/parse false) keys sort))))
(let [info-res (api-get (str "ledger/" ledger-name "/:info") {})]
(is (= 200 (:status info-res)))
(is (= ["address" "alias" "branch" "commit" "index" "namespace-codes" "stats" "t"]
(-> info-res :body (json/parse false) keys sort)))))

(testing "nonmatching routes are handled uniformly"
(let [not-found1 (api-post "foo" {:body "{}" :headers json-headers})
not-found2 (api-post (str "ledger/" ledger-name "/:foo") {:body "{}" :headers json-headers})]
Expand Down
Loading