You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Each extension consists of client-side and server-side part. Client-side means resources, which are living inside client's browser, e.g. HTML, Javascript, CSS, images etc.

Server-side part, API endpoints, are executed on the server and can be called from the outside using HTTP request. 

When to create API endpoint

There are several situations, where you need a specific endpoint for your application:

  • Custom business logic is required
  • Calling 3rd party systems is necessary
  • Client API does not offer desired functions

Specification

An API Endpoint is Groovy/Java class compiled and executed on the server at runtime. It may use 3rd party JAR libraries provided as JAR resource inside the extension.

On the source code level, it's possible to use variety of classes and methods, including access to basic BellaDati objects and data - Data sets, Reports, Machine Learning.

 

Endpoint URL
http://belladati_host/extension/detail:endpoint/EXT_ID/ENDPOINT_NAME
http://belladati_host/ext/detail?id=EXT_ID&action=ENDPOINT_NAME


Structure

package com.belladati;
import com.belladati.extension.BaseExtensionEndpoint;
import org.apache.tapestry5.StreamResponse;
public class MyEndpoint extends BaseExtensionEndpoint {
	@Override
	public StreamResponse doGet() {
		String text = "GET method called with parameter: " + getParameter("say")
		return createStreamResponse(text, "text/plain", 200);
	}
	@Override
	public StreamResponse doPost() {
		String text = "POST method called with parameter: " + getParameter("say")
		return createStreamResponse(text, "text/plain", 200);
	}
}
  • No labels