Hilla Documentation

Endpoint URLs

How endpoint URLs are composed in Hilla, and how to modify them.

Hilla automatically generates endpoint URLs and wraps them in the generated TypeScript API, so the developer doesn’t need to worry about them. As a reference, this article describes how the endpoint URLs are composed and how to modify them.

How the API Endpoint URL Is Composed

Any public method in any Hilla endpoint can be accessed with the following URL:

http://${base_url}/${prefix}/${endpoint_name}/${method_name}

where:

  • ${base_url} – The base URL of the application, depending on the framework used. For instance, for the Spring framework, the default URL if the application is started locally is http://localhost:8080. If the application is started with a context, it should be added to the end; for instance, http://localhost:8080/my-app.

  • ${prefix} – The URL common part that every exposed endpoint has. By default, connect is used, but this can be configured in the application properties.

  • ${endpoint_name} – By default, this is the corresponding Java class name which exposes methods, although this can be changed in the @Endpoint annotation value.

  • ${method_name} – The public method name from the Java class.

For an application started locally with the CounterEndpoint endpoint defined as shown, the endpoint URL will be: http://localhost:8080/connect/counterendpoint/addone

@Endpoint
public class CounterEndpoint {

    public int addOne(int number) {
        return number + 1;
    }
}
Note

The endpoint name and the method name aren’t case-sensitive in Hilla, so the URL shown is the same as http://localhost:8080/connect/CounterEndpoint/addOne or http://localhost:8080/connect/COUNTERENDPOINT/ADDONE, or any other case combination for the endpoint and method name.

How to Configure the API Endpoint URL

Hilla allows you to configure the following parts of the URL:

  • ${prefix} – The default value is connect. To change it to some other value, provide an application.properties file in the project resources (src/main/resources/application.properties) and set the vaadin.endpoint.prefix property to the new value.

  • ${endpoint_name} – By default, the simple name of the Java class is taken. It’s possible to specify a value in the @Endpoint annotation to override default one (@Endpoint("customName")). In this case, the customName value will be used as a ${endpoint_name} to accept incoming requests; it’s also case-insensitive.