X

Best Practices from Oracle Development's A‑Team

Handling different HTTP methods in Oracle Fn

Derek Kam
Consulting Solutions Architect

In this blog, I will demonstrate how to handle different HTTP verbs (POST, GET, DELETE, and PATCH) in Oracle Fn. I will use Java and NodeJS to demonstrate.

In FnProject, if you are using the default mechanism "invoke" to call your function, it will be using the HTTP post method, so if you want to call your functions with other HTTP methods like HTTP get or other HTTP PUT, etc, you need to use the trigger function in Fn, as the trigger function support all HTTP verbs. However, Oracle Fn doesn’t support the trigger function.

To handle all HTTP verbs in Oracle Fn, you can add HTTPGatewayContext as one of the parameters to your function. If you want to access the payload in the request body in Java, you can add InputEvent to your function parameter.

To test the code you need to configure the API Gateway to accept the HTTP verbs you require. See here for more details on how to configure a function as an API Gateway backend, after that you can test your function using curl, e.g. curl -X GET  https://<API Gateway URL>

Java Function Sample:

Nodejs  Function Sample:

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha