atscppapi
1.0.9
C++ wrapper for Apache Traffic Server API
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Enumerations
Enumerator
Macros
src
include
atscppapi
GlobalPlugin.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 GlobalPlugin.h
15
* @author Brian Geffon
16
* @author Manjesh Nilange
17
* @brief Contains the interface used in creating Global plugins.
18
*/
19
20
#pragma once
21
#ifndef ATSCPPAPI_GLOBALPLUGIN_H_
22
#define ATSCPPAPI_GLOBALPLUGIN_H_
23
24
#include <
atscppapi/Plugin.h
>
25
26
namespace
atscppapi {
27
28
class
GlobalPluginState;
29
30
/**
31
* @brief The interface used when creating a GlobalPlugin.
32
*
33
* A GlobalPlugin is a Plugin that will fire for a given hook on all Transactions.
34
* In otherwords, a GlobalPlugin is not tied to a specific plugin, a Transaction
35
* specific plugin would be a TransactionPlugin.
36
*
37
* Depending on the
38
* type of hook you choose to build you will implement one or more callback methods.
39
* Here is a simple example of a GlobalPlugin:
40
*
41
* \code
42
* class GlobalHookPlugin : public GlobalPlugin {
43
* public:
44
* GlobalHookPlugin() {
45
* registerHook(HOOK_READ_REQUEST_HEADERS_PRE_REMAP);
46
* }
47
* virtual void handleReadRequestHeadersPreRemap(Transaction &transaction) {
48
* std::cout << "Hello from handleReadRequesHeadersPreRemap!" << std::endl;
49
* transaction.resume();
50
* }
51
* };
52
* \endcode
53
* @see Plugin
54
*/
55
class
GlobalPlugin
:
public
Plugin
{
56
public
:
57
/**
58
* registerHook is the mechanism used to attach a global hook.
59
*
60
* \note Whenever you register a hook you must have the appropriate callback definied in your GlobalPlugin
61
* see HookType and Plugin for the correspond HookTypes and callback methods. If you fail to implement the
62
* callback, a default implmentation will be used that will only resume the Transaction.
63
*
64
* @param HookType the type of hook you wish to register
65
* @see HookType
66
* @see Plugin
67
*/
68
void
registerHook
(
Plugin::HookType
);
69
virtual
~
GlobalPlugin
();
70
protected
:
71
/**
72
* Constructor.
73
*
74
* @param ignore_internal_transactions When true, all hooks registered by this plugin are ignored
75
* for internal transactions (internal transactions are created
76
* when other plugins create requests). Defaults to false.
77
*/
78
GlobalPlugin
(
bool
ignore_internal_transactions =
false
);
79
private
:
80
GlobalPluginState *state_;
/**< Internal state tied to a GlobalPlugin */
81
};
82
83
}
/* atscppapi */
84
85
86
#endif
/* ATSCPPAPI_GLOBALPLUGIN_H_ */
Generated on Mon Oct 14 2013 11:39:29 for atscppapi by
1.8.3.1