set a header with the session id (for logging purposes)

Setting a header is the easiest way to plumb something up to apache for
logging in the apache log.

Change-Id: I83fac94de5b4d5a62c976bde9b90f8390f7eb8a1
Reviewed-on: https://gerrit.instructure.com/12219
Tested-by: Zach Wily <zach@instructure.com>
Reviewed-by: Brian Palmer <brianp@instructure.com>
This commit is contained in:
Zach Wily 2012-07-13 08:15:18 -06:00
parent 544f59dee7
commit 2a07303c73
1 changed files with 6 additions and 0 deletions

View File

@ -32,7 +32,13 @@ class RequestContextGenerator
}
status, headers, body = @app.call(env)
# The session id may have been reset in the request, in which case
# we want to log the new one,
session_id = (env['rack.session.options'] || {})[:id]
headers['X-Session-Id'] = session_id if session_id
headers['X-Request-Context-Id'] = request_id
[ status, headers, body ]
end