Use your beloved libraries in SLINGR

Diego Gaviola
SLINGR.io
Published in
3 min readJul 15, 2019

Endpoints in SLINGR are commonly used to integrate with other apps. However, it is also possible to use them to extend the functionality of the SLINGR Platform.

Although the SLINGR Platform is a general-purpose and you can get done almost anything you need, there are cases where you still need a Java library that provides some specific functionality not available. For example, you need to render an HTML file and generate a PDF out of it. There are Java libraries that can do that, but you cannot directly use them from SLINGR.

Here is where endpoints can be used to address this problem. Even though endpoints are usually associated with integrations, they can also be used to extend SLINGR, as a bridge between your app and any Java library.

Now we will briefly explain the steps in order to create an endpoint that can hold your Java library.

Create a new endpoint project

The first step is to create a new endpoint project. The best way to do it is to start from a template, as explained here.

This project needs to be uploaded to an open Git repository (no security). If you want to make it private, you should use GitHub and give read-access to user slingr-builder.

Add your libraries

The next step is to add the library you want to use in SLINGR. You can easily accomplish this by adding the library to the POM file in your project. When SLINGR builds your endpoint, it will use the POM file to do it, so you can manage dependencies there.

Expose the library in your endpoint

Once you have the endpoint with your library, you need to expose the things you need in your app. The most common way to do this is by defining functions in the endpoint. These functions need to be defined in the endpoint.json file:

{
"name": "test",
"label": "Test",
...
"functions": [
"label": "Call my library",
"name": "callMyLib"
],
...
}

Then, in your endpoint class, you will add something like this:

@EndpointFunction
public Json callMyLib(FunctionRequest request) {
final Json data = request.getJsonParams();
Json res = Json.map();
// call your lib and do something
return res;
}

You can find many samples in the code of the following endpoints:

Test it through the proxy endpoint

Before registering and packaging your endpoint, it is good to test it through a proxy endpoint.

Using the proxy endpoint during development has several advantages:

  • No need to package a new version to test changes in your endpoint
  • No need to commit/push changes to the Git repository
  • You can debug your endpoint locally
  • No need to register your endpoint in SLINGR

Here you can find more information about how to develop using the proxy endpoint.

Register your endpoint

Once your endpoint is working as expected, the last step is to register it in the SLINGR platform so it can be used in apps. This can be done as explained in the official documentation.

Here you can choose if you want your endpoint to be private, where it will be available only to apps under your account, or make it public and contribute it to the community :)

Conclusion

Even though endpoints are usually in charge of integrating with other services, it is also possible to use them to extend the SLINGR Platform and access any Java library that you need in your app.

SLINGR is a low-code rapid application development platform that accelerates development, with robust architecture for integrations and executing custom workflows and automation.

More info about SLINGR

--

--

Diego Gaviola
SLINGR.io

Passionate about software development and blockchain. CTO of SLINGR.