writing-jar-api

Writing JAR API

You can create your own API by writing a server side logic. To create your own API, just download API Sample eclipse sample project and import this in to your eclipse. You will find a sample java file in side it named as com.test.MyAPI. This class implements Executor interface and you can write your logic inside execute method as shown below. Also, you are free to rename this class file based on your requirement.

public class MyAPI implements Executor { @Override public HttpResponseObject execute(HttpRequestObject requestObject) { //Get Request Body String requestBody = requestObject.getBody(); //Get Header Map HashMap requestHeaders = requestObject.getHeaderMap(); // ########### Write your Logic Below ############// //…………………………………………// //…………………………………………// //…………………………………………// // ########### Logic End ############// // Send Your Response….. HashMap responseHeader = new HashMap(); responseHeader.put(“MyCustomHeader”, “XXXXXXX”); int responseStatus = 200; // OK… String responseMessage = “{‘message’:'Success/Custom Message’}”; // You can pass your custom message return new HttpResponseObject(responseStatus, responseMessage , responseHeader); } }



Once you got the access token, you can pass this in your API call to App42 API gateway for authentication. API gateway will do all the validation and authentication on it and allow the API call if it is valid access token.