atscppapi  1.0.9
C++ wrapper for Apache Traffic Server API
 All Classes Files Functions Enumerations Enumerator Macros
RemapPlugin.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 LinkedIn Corp. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
4  * except in compliance with the License. You may obtain a copy of the license at
5  * http://www.apache.org/licenses/LICENSE-2.0
6  *
7  * Unless required by applicable law or agreed to in writing, software distributed under the
8  * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
9  * either express or implied.
10  *
11  */
12 
13 /**
14  * @file RemapPlugin.h
15  * @author Brian Geffon
16  * @author Manjesh Nilange
17  */
18 
19 #pragma once
20 #ifndef ATSCPPAPI_REMAP_PLUGIN_H_
21 #define ATSCPPAPI_REMAP_PLUGIN_H_
22 
23 #include "atscppapi/Transaction.h"
24 #include "atscppapi/Url.h"
25 
26 namespace atscppapi {
27 
28 /**
29  * @brief Base class that remap plugins should extend.
30  */
31 class RemapPlugin {
32 public:
33  /**
34  * Constructor
35  *
36  * @param instance_handle The instance_handle argument received in TSRemapInit() should be passed here.
37  */
38  RemapPlugin(void **instance_handle);
39 
40  enum Result { RESULT_ERROR = 0, RESULT_NO_REMAP, RESULT_DID_REMAP, RESULT_NO_REMAP_STOP,
41  RESULT_DID_REMAP_STOP };
42 
43  /**
44  * Invoked when a request matches the remap.config line - implementation should perform the
45  * remap. The client's URL is in the transaction and that's where it should be modified.
46  *
47  * @param map_from_url The map from URL specified in the remap.config line.
48  * @param map_to_url The map to URL specified in the remap.config line.
49  * @param transaction Transaction
50  * @param redirect Output argument that should be set to true if the (new) url should be used
51  * as a redirect.
52  *
53  * @return Result of the remap - will dictate futher processing by the system.
54  */
55  virtual Result doRemap(const Url &map_from_url, const Url &map_to_url, Transaction &transaction,
56  bool &redirect) {
57  return RESULT_NO_REMAP;
58  }
59 
60  virtual ~RemapPlugin() { }
61 };
62 
63 }
64 
65 #endif