You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ca...@apache.org on 2020/03/05 18:18:18 UTC
[trafficserver] branch master updated: [CPPAPI] Provide access to
TSRemapRequestInfo in RemapPlugins.
This is an automated email from the ASF dual-hosted git repository.
calavera pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new c27f09c [CPPAPI] Provide access to TSRemapRequestInfo in RemapPlugins.
c27f09c is described below
commit c27f09ca411a1be9ae03af4834d29816f3088627
Author: David Calavera <da...@gmail.com>
AuthorDate: Thu Feb 27 11:26:30 2020 -0800
[CPPAPI] Provide access to TSRemapRequestInfo in RemapPlugins.
Add a new virtual method that gives you more control over
how a remap happens in a RemapPlugin.
Signed-off-by: David Calavera <da...@gmail.com>
---
include/tscpp/api/RemapPlugin.h | 20 ++++++++++++++++++++
src/tscpp/api/RemapPlugin.cc | 7 ++-----
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/include/tscpp/api/RemapPlugin.h b/include/tscpp/api/RemapPlugin.h
index 44e550e..e69cbb6 100644
--- a/include/tscpp/api/RemapPlugin.h
+++ b/include/tscpp/api/RemapPlugin.h
@@ -25,6 +25,7 @@
#include "tscpp/api/Transaction.h"
#include "tscpp/api/Url.h"
#include "tscpp/api/utils.h"
+#include "ts/remap.h"
namespace atscppapi
{
@@ -50,6 +51,25 @@ public:
};
/**
+ * Invoked when a request matches the remap.config line - it gives you access to the remap information
+ * if you want to have more control over how the remap happens.
+ *
+ * @param transaction Transaction
+ * @param rri The remap information in the remap.config line.
+ *
+ * @return Result of the remap - will dictate further processing by the system.
+ */
+ virtual Result
+ remapTransaction(Transaction &transaction, TSRemapRequestInfo *rri)
+ {
+ Url map_from_url(rri->requestBufp, rri->mapFromUrl), map_to_url(rri->requestBufp, rri->mapToUrl);
+ bool redirect = false;
+ RemapPlugin::Result result = doRemap(map_from_url, map_to_url, transaction, redirect);
+ rri->redirect = redirect ? 1 : 0;
+ return result;
+ }
+
+ /**
* Invoked when a request matches the remap.config line - implementation should perform the
* remap. The client's URL is in the transaction and that's where it should be modified.
*
diff --git a/src/tscpp/api/RemapPlugin.cc b/src/tscpp/api/RemapPlugin.cc
index 7be742c..2e9bb1e 100644
--- a/src/tscpp/api/RemapPlugin.cc
+++ b/src/tscpp/api/RemapPlugin.cc
@@ -30,12 +30,9 @@ using namespace atscppapi;
TSRemapStatus
TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri)
{
- RemapPlugin *remap_plugin = static_cast<RemapPlugin *>(ih);
- Url map_from_url(rri->requestBufp, rri->mapFromUrl), map_to_url(rri->requestBufp, rri->mapToUrl);
+ RemapPlugin *remap_plugin = static_cast<RemapPlugin *>(ih);
Transaction &transaction = utils::internal::getTransaction(rh);
- bool redirect = false;
- RemapPlugin::Result result = remap_plugin->doRemap(map_from_url, map_to_url, transaction, redirect);
- rri->redirect = redirect ? 1 : 0;
+ RemapPlugin::Result result = remap_plugin->remapTransaction(transaction, rri);
switch (result) {
case RemapPlugin::RESULT_ERROR:
return TSREMAP_ERROR;