How can I access the API related information like API Properties (defined in publisher) in the WSO2 Custom handler?
You can use message context object to access API information:
messageContext.getProperty("api.ut.HTTP_METHOD")
Refer sample for more info.
Refer the below code. It will print all the messagecontext property key set and their values.
Set propertySet = context.getPropertyKeySet();
for (Object propertyKey : propertySet) {
log.info("Key: " + propertyKey.toString() + "| value: "
+ context.getProperty(propertyKey.toString()));
}
Also refer this
As I can see handler/mediator can have access to api properties via local registry
When defined in xml configuration it can be like this
<sequence name="custom-sequence" xmlns="http://ws.apache.org/ns/synapse">
<log level="custom">
<property
name="prop"
expression="get-property('registry',
fn:concat(
'gov:/apimgt/applicationdata/provider/',
$ctx:api.ut.apiPublisher, '/',
$ctx:api.ut.api, '/',
$ctx:api.ut.version, '/',
'api@api_meta.my_property'
))" />
</log>
</sequence>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.