kubeless icon indicating copy to clipboard operation
kubeless copied to clipboard

Access HTTP path parameters in Java JVM project

Open dennisMKI opened this issue 3 years ago • 0 comments

I'm trying to access HTTP path parameters ("/function-name?key=value") using the JVM Java example. However, having a closer look to the Gradle compile group it seems like the project using a implementation of the io.kubeless.Event Class by inoio:

compile group: 'de.inoio.kubeless', name: 'jvm-runtime', version: '0.1'

Refers to Sonatype Kubeless Maven respectively Event and Context Implementation by inoio. The Event class implements only a Data String:

public class Event {
	String Data;
	String EventID;
	String EventType;
	String EventTime;
	String EventNamespace;
    public Event(String data, String eventId, String eventType, String eventTime, String eventNamespace) {
        this.Data = data;
        this.EventID = eventId;
        this.EventType = eventType;
        this.EventTime = eventTime;
        this.EventNamespace = eventNamespace;
    }
}

So there are two things:

  1. The implementation of the data variable as a string without a getter allows a Java class to access the object variable only if the class is located in the same package. The JVM Java example uses a different package path "io.inoio", so that no access is possible from there. Changing the package path of my handler class to "io.kubeless" solves this problem.

  2. Data variable returns only the request body. image I expected that it contains additional information like the YAML representation of a Kafka event as JSON in Kubeless Functions - Functions Interface including full path and path parameters.

I'm trying to implement a function using multiple classes, additional dependencies like okhttp3 and gson, java packages, http request body and http parameters. It seems like most of this is only possible using the java JVM example instead of the classic java example , but I cannot see a way to access HTTP parameters.

Is there a way to implement my requirements in Java? Is it usually possible to access HTTP parameters in Kubeless - perhaps with another programming language? And is it usually possible to access HTTP query string parameters like "/function-name/some/thing/else"?

I appreciate your help!

Best regards Dennis

dennisMKI avatar Jul 14 '20 10:07 dennisMKI