Added HTTP request logging to the /files endpoint. Review: https://reviews.apache.org/r/58223/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/eeafd042 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/eeafd042 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/eeafd042 Branch: refs/heads/master Commit: eeafd0425fb46c524b81a4c277e551b5e41af105 Parents: 8aad935 Author: James Peach <[email protected]> Authored: Thu Apr 6 13:12:30 2017 -0700 Committer: Anand Mazumdar <[email protected]> Committed: Thu Apr 6 13:13:25 2017 -0700 ---------------------------------------------------------------------- src/files/files.cpp | 98 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 65 insertions(+), 33 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/eeafd042/src/files/files.cpp ---------------------------------------------------------------------- diff --git a/src/files/files.cpp b/src/files/files.cpp index f066146..b03279e 100644 --- a/src/files/files.cpp +++ b/src/files/files.cpp @@ -205,69 +205,101 @@ FilesProcess::FilesProcess( void FilesProcess::initialize() { if (authenticationRealm.isSome()) { + auto browse_ = [this]( + const http::Request& request, + const Option<Principal>& principal) { + logRequest(request); + return _browse(request, principal); + }; + + auto read_ = [this]( + const http::Request& request, + const Option<Principal>& principal) { + logRequest(request); + return __read(request, principal); + }; + + auto download_ = [this]( + const http::Request& request, + const Option<Principal>& principal) { + logRequest(request); + return download(request, principal); + }; + + auto debug_ = [this]( + const http::Request& request, + const Option<Principal>& principal) { + logRequest(request); + return debug(request, principal); + }; + // TODO(ijimenez): Remove these endpoints at the end of the // deprecation cycle on 0.26. route("/browse.json", authenticationRealm.get(), FilesProcess::BROWSE_HELP, - &FilesProcess::_browse); + browse_); route("/read.json", authenticationRealm.get(), FilesProcess::READ_HELP, - &FilesProcess::__read); + read_); route("/download.json", authenticationRealm.get(), FilesProcess::DOWNLOAD_HELP, - &FilesProcess::download); + download_); route("/debug.json", authenticationRealm.get(), FilesProcess::DEBUG_HELP, - &FilesProcess::debug); + debug_); route("/browse", authenticationRealm.get(), FilesProcess::BROWSE_HELP, - &FilesProcess::_browse); + browse_); route("/read", authenticationRealm.get(), FilesProcess::READ_HELP, - &FilesProcess::__read); + read_); route("/download", authenticationRealm.get(), FilesProcess::DOWNLOAD_HELP, - &FilesProcess::download); + download_); route("/debug", authenticationRealm.get(), FilesProcess::DEBUG_HELP, - &FilesProcess::debug); + debug_); } else { + auto browse_ = [this](const http::Request& request) { + logRequest(request); + return _browse(request, None()); + }; + + auto read_ = [this](const http::Request& request) { + logRequest(request); + return __read(request, None()); + }; + + auto download_ = [this](const http::Request& request) { + logRequest(request); + return download(request, None()); + }; + + auto debug_ = [this](const http::Request& request) { + logRequest(request); + return debug(request, None()); + }; + // TODO(ijimenez): Remove these endpoints at the end of the // deprecation cycle on 0.26. - route("/browse.json", - FilesProcess::BROWSE_HELP, - lambda::bind(&FilesProcess::_browse, this, lambda::_1, None())); - route("/read.json", - FilesProcess::READ_HELP, - lambda::bind(&FilesProcess::__read, this, lambda::_1, None())); - route("/download.json", - FilesProcess::DOWNLOAD_HELP, - lambda::bind(&FilesProcess::download, this, lambda::_1, None())); - route("/debug.json", - FilesProcess::DEBUG_HELP, - lambda::bind(&FilesProcess::debug, this, lambda::_1, None())); - - route("/browse", - FilesProcess::BROWSE_HELP, - lambda::bind(&FilesProcess::_browse, this, lambda::_1, None())); - route("/read", - FilesProcess::READ_HELP, - lambda::bind(&FilesProcess::__read, this, lambda::_1, None())); - route("/download", - FilesProcess::DOWNLOAD_HELP, - lambda::bind(&FilesProcess::download, this, lambda::_1, None())); - route("/debug", - FilesProcess::DEBUG_HELP, - lambda::bind(&FilesProcess::debug, this, lambda::_1, None())); + route("/browse.json", FilesProcess::BROWSE_HELP, browse_); + route("/read.json", FilesProcess::READ_HELP, read_); + route("/download.json", FilesProcess::DOWNLOAD_HELP, download_); + route("/debug.json", FilesProcess::DEBUG_HELP, debug_); + + route("/browse", FilesProcess::BROWSE_HELP, browse_); + route("/read", FilesProcess::READ_HELP, read_); + route("/download", FilesProcess::DOWNLOAD_HELP, download_); + route("/debug", FilesProcess::DEBUG_HELP, debug_); } }
