File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1111 - #3171 , Add an ability to dump config via admin API - @skywriter
1212 - #3061 , Apply all function settings as transaction-scoped settings - @taimoorzaeem
1313 - #3171 , Log schema cache stats to stderr - @steve-chavez
14+ - #3210 , Dump schema cache through admin API - @taimoorzaeem
1415
1516### Fixed
1617
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ module PostgREST.Admin
44 ( runAdmin
55 ) where
66
7+ import qualified Data.Aeson as JSON
78import qualified Hasql.Session as SQL
89import qualified Network.HTTP.Types.Status as HTTP
910import qualified Network.Wai as Wai
@@ -51,6 +52,9 @@ admin appState appConfig req respond = do
5152 [" config" ] -> do
5253 config <- AppState. getConfig appState
5354 respond $ Wai. responseLBS HTTP. status200 [] (LBS. fromStrict $ encodeUtf8 $ Config. toText config)
55+ [" schema_cache" ] -> do
56+ sCache <- AppState. getSchemaCache appState
57+ respond $ Wai. responseLBS HTTP. status200 [] (maybe mempty JSON. encode sCache)
5458 _ ->
5559 respond $ Wai. responseLBS HTTP. status404 [] mempty
5660
Original file line number Diff line number Diff line change @@ -642,6 +642,15 @@ def test_admin_config(defaultenv):
642642 assert "admin-server-port" in response .text
643643
644644
645+ def test_admin_schema_cache (defaultenv ):
646+ "Should get a success response from the admin server containing current schema cache"
647+
648+ with run (env = defaultenv ) as postgrest :
649+ response = postgrest .admin .get ("/schema_cache" )
650+ assert response .status_code == 200
651+ assert '"dbTables":[[{"qiName":"authors_only"' in response .text
652+
653+
645654def test_admin_ready_w_channel (defaultenv ):
646655 "Should get a success response from the admin server ready endpoint when the LISTEN channel is enabled"
647656
You can’t perform that action at this time.
0 commit comments