Endpoint URLs
Vaadin automatically generates endpoint URLs and wraps them in the generated TypeScript API so as the developer does not need to care 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 Vaadin 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, depends on the framework used. For instance, for Spring framework, the default one if the application is started locally, ishttp://localhost:8080. If the application is started with a context, it should be added to the end for instancehttp://localhost:8080/my-app${prefix}— the url common part that every exposed endpoint has. By default,connectis used, but this can be configured in the application properties.${endpoint_name}— By default it is the corresponding Java class name which exposes methods. Though it can be changed in the@Endpointannotation value.${method_name}— the public method name from the Java class.
For the application started locally with the CounterEndpoint endpoint defined
below, the endpoint url will be the following:
http://localhost:8080/connect/counterendpoint/addone
@Endpoint
public class CounterEndpoint {
public int addOne(int number) {
return number + 1;
}
}Note | Endpoint name and the method name are not case sensitive for Vaadin, so
the url above is the same as
|
How to configure the API endpoint URL
Vaadin allows to configure the following url parts:
${prefix}The default value isconnect. To change it to some other value, provideapplication.propertiesfile in the project resources:src/main/resources/application.propertiesand set thevaadin.connect.prefixproperty to the new value.${endpoint_name}By default, the Java class simple name is taken. It is possible to specify a value in the@Endpointannotation to override default one:@Endpoint("customName"). In this case, thecustomNamevalue will be used as a${endpoint_name}to accept incoming requests, also case-insensitive.