CoProcessMessage
data structure like the one described in api.h
, where p_data
is a pointer to the serialised data and length
indicates the length of it.
CoProcessObject
data structure.
HookType
- the hook type (see below)Request
- the HTTP requestSession
- the Tyk session object.Metadata
- the metadata from the session data above (key/value string map).Spec
- the API specification data. Currently organization ID, API ID and config_data.Coprocess.Dispatcher
describes a very simple interface for implementing the dispatcher logic, the required methods are: Dispatch
, DispatchEvent
and Reload
.
Dispatch
accepts a pointer to a struct CoProcessObject
(as described above) and must return an object of the same type. This method will be called for every configured hook on every request. Traditionally this method will perform a single function call on the target language side (like Python_DispatchHook
in coprocess_python
), and the corresponding logic will be handled from there (mostly because different languages have different ways of loading, referencing or calling middlewares).
DispatchEvent
provides a way of dispatching Tyk events to a target language. This method doesn’t return any variables but does receive a JSON-encoded object containing the event data. For extensibility purposes, this method doesn’t use Protocol Buffers, the input is a []byte
, the target language will take this (as a char
) and perform the JSON decoding operation.
Reload
is called when triggering a hot reload, this method could be useful for reloading scripts or modules in the target language.
coprocess_api.go
provides a bridge between the Gateway API and C. Any function that needs to be exported should have the export
keyword:
api.h
, like this:
auth_check
).