siva siva - 7 months ago 85
JSON Question

wso2 API Manager custom validations for API request input feilds

is there any sample code who can help for my below requirement.
i am publishing Rest APIs in WSO2 API Manager , i would like to intercept my own API input field validations for each API like input parameter format and value etc .If validation success then API Manager should allow the request to invoke back-end , else reject the request with error message.

I have gone though some documents and i understand we can acheive this by adding mediation extensions and custom hanlder,however i couldn't find any sample code for this.

If we are writing custom handler , should we write it for each API and do config changes in API Synapsis file?
I would like to have a single handler which will invoke for All APIs, and handler will execute the corresponding method which is applicable for that specific API .

Can you please suggest how to achieve this??

Thanks in Advance


You can have single custom handler which will be used by all APIs. You can use the latest version of the API Manager which is 1.9.1

You can extend the API Manager to support any custom authentication mechanism by writing your own authentication handler class. This custom handler must extend class and implement the handleRequest() and handleResponse() methods.

You can find a sample implementation here. For more details, please have a look on Writing Custom Handlers