Hi,
I’m trying to write an interceptor to add a custom header for authentication to our backend api’s.
To calculate the header, I need the following caller fields :
mimetype
method (post/get/delete/etc)
path
body (as string/json etc)
I am starting with the Java sample (tyk-plugin-demo-java), but cannot see a way to access the http method (get/put/post/delete) or the mime type.
I am overriding as follows, but hardcoding for now :
CoprocessObject.Object MyPreHook(CoprocessObject.Object request) { CoprocessObject.Object.Builder builder = request.toBuilder(); String body = request.getRequest().getBody(); String path = request.getRequest().getUrl(); // TODO - how do we know if this is a GET or a POST? String method = "GET"; String mime = "application/json";
Could anyone suggest how to unwrap this?
thanks