A brief file description
@section license License
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#pragma once
#define TSREMAP_VMAJOR 3
#define TSREMAP_VMINOR 0
#define TSREMAP_VERSION ((TSREMAP_VMAJOR << 16) | TSREMAP_VMINOR)
struct TSRemapInterface {
unsigned long size;
unsigned long tsremap_version;
TSRemapPluginInfo plugin_info;
};
struct TSRemapRequestInfo {
TSMLoc mapFromUrl;
TSMLoc mapToUrl;
requestUrl using normal ts/ts.h APIs, which is how you change the destination URL. */
TSMLoc requestUrl;
TSMBuffer requestBufp;
TSMLoc requestHdrp;
int redirect;
};
enum TSRemapStatus {
TSREMAP_NO_REMAP = 0,
TSREMAP_DID_REMAP = 1,
TSREMAP_NO_REMAP_STOP = 2,
TSREMAP_DID_REMAP_STOP = 3,
-400 to -499
-500 to -599
....
This would allow a plugin to generate an error page. Right now,
setting the return code to any negative number is equivalent to TSREMAP_NO_REMAP */
TSREMAP_ERROR = -1,
};
* (1) if the configuration reload was successful and
* (2) if (1) is successful show if the plugin was part of the new configuration */
enum TSRemapReloadStatus {
TSREMAP_CONFIG_RELOAD_FAILURE = 0,
TSREMAP_CONFIG_RELOAD_SUCCESS_PLUGIN_USED = 1,
TSREMAP_CONFIG_RELOAD_SUCCESS_PLUGIN_UNUSED =
2,
};
These are the entry points a plugin can implement. Note that TSRemapInit() and
TSRemapDoRemap() are both required. (These functions are called from TS using dlsym(),
so they must be undecorated / extern "C".)
----------------------------------------------------------------------------------
*/
Mandatory interface function.
Return: TS_SUCCESS
TS_ERROR - error, errbuf can include error message from plugin
*/
extern "C" TSReturnCode TSRemapInit(TSRemapInterface *api_info, char *errbuf, int errbuf_size);
to TSRemapInit() which gets called when the plugin is first loaded.
It is guaranteed to be called before TSRemapInit() and TSRemapNewInstance().
It cannot fail, or cause reload to stop here, it's merely a notification.
Optional function.
Params: none
Return: none
*/
extern "C" void TSRemapPreConfigReload(void);
to TSRemapInit() which gets called when the plugin is first loaded.
It is guaranteed to be called after TSRemapInit() and TSRemapNewInstance().
It cannot fail, or cause reload to stop here, it's merely a notification that
the (re)load is done and provide a status of its success or failure..
Optional function.
Params: reloadStatus - TS_SUCCESS - (re)load was successful,
TS_ERROR - (re)load failed.
Return: none
*/
extern "C" void TSRemapPostConfigReload(TSRemapReloadStatus reloadStatus);
Mandatory interface function.
Remap API plugin can/should use SDK API function calls inside this function!
return: TSREMAP_NO_REMAP - No remapping was done, continue with next in chain
TSREMAP_DID_REMAP - Remapping was done, continue with next in chain
TSREMAP_NO_REMAP_STOP - No remapping was done, and stop plugin chain evaluation
TSREMAP_DID_REMAP_STOP - Remapping was done, but stop plugin chain evaluation
*/
extern "C" TSRemapStatus TSRemapDoRemap(void *ih, TSHttpTxn rh, TSRemapRequestInfo *rri);
Optional function. */
extern "C" void TSRemapDone(void);
First two arguments in argv vector are - fromURL and toURL from remap record.
Please keep in mind that fromURL and toURL will be converted to canonical view.
Return: TS_SUCCESS
TS_ERROR - instance creation error
*/
extern "C" TSReturnCode TSRemapNewInstance(int argc, char *argv[], void **ih, char *errbuf, int errbuf_size);
extern "C" void TSRemapDeleteInstance(void *);
os_response_type -> TSServerState
Remap API plugin can use InkAPI function calls inside TSRemapDoRemap()
Return: none
*/
extern "C" void TSRemapOSResponse(void *ih, TSHttpTxn rh, int os_response_type);