feat: Add current user to apache-style request logging.
This commit is contained in:
committed by
Wolfgang Walther
parent
3c17f97c87
commit
9639cd5751
@@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
+ For enabling this, the `admin-server-port` config must be set explictly
|
||||
+ A `<host>:<admin_server_port>/live` endpoint is available for checking if postgrest is running on its port/socket. 200 OK = alive, 503 = dead.
|
||||
+ A `<host>:<admin_server_port>/ready` endpoint is available for checking a correct internal state(the database connection plus the schema cache). 200 OK = ready, 503 = not ready.
|
||||
- #1988, Add the current user to the request log on stdout - @DavidLindbom, @wolfgangwalther
|
||||
|
||||
### Fixed
|
||||
|
||||
|
||||
@@ -10,7 +10,8 @@ import qualified Network.Wai.Middleware.RequestLogger as Wai
|
||||
import Network.HTTP.Types.Status (status400, status500)
|
||||
import System.IO.Unsafe (unsafePerformIO)
|
||||
|
||||
import PostgREST.Config (LogLevel (..))
|
||||
import qualified PostgREST.Auth as Auth
|
||||
import PostgREST.Config (LogLevel (..))
|
||||
|
||||
import Protolude
|
||||
|
||||
@@ -25,4 +26,5 @@ middleware logLevel = case logLevel of
|
||||
{ Wai.outputFormat = Wai.ApacheWithSettings $
|
||||
Wai.defaultApacheSettings
|
||||
& Wai.setApacheRequestFilter (\_ res -> filterStatus $ Wai.responseStatus res)
|
||||
& Wai.setApacheUserGetter (fmap encodeUtf8 . Auth.getRole)
|
||||
}
|
||||
|
||||
+2
-2
@@ -856,7 +856,7 @@ def test_log_level(level, has_output, defaultenv):
|
||||
assert response.status_code == 200
|
||||
if has_output[0]:
|
||||
assert re.match(
|
||||
r'unknownSocket - - \[.+\] "GET / HTTP/1.1" 200 - "" "python-requests/.+"',
|
||||
r'unknownSocket - postgrest_test_anonymous \[.+\] "GET / HTTP/1.1" 200 - "" "python-requests/.+"',
|
||||
postgrest.process.stdout.readline().decode(),
|
||||
)
|
||||
|
||||
@@ -864,7 +864,7 @@ def test_log_level(level, has_output, defaultenv):
|
||||
assert response.status_code == 404
|
||||
if has_output[1]:
|
||||
assert re.match(
|
||||
r'unknownSocket - - \[.+\] "GET /unknown HTTP/1.1" 404 - "" "python-requests/.+"',
|
||||
r'unknownSocket - postgrest_test_anonymous \[.+\] "GET /unknown HTTP/1.1" 404 - "" "python-requests/.+"',
|
||||
postgrest.process.stdout.readline().decode(),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user