title | order | layout |
---|---|---|
Appendix: Endpoint URLs |
160 |
page |
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.
Any public method in any Vaadin endpoint can be accessed with the following url:
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,connect
is 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@Endpoint
annotation 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
|
Vaadin allows to configure the following url parts:
-
${prefix}
The default value isconnect
. To change it to some other value, provideapplication.properties
file in the project resources:src/main/resources/application.properties
and set thevaadin.connect.prefix
property to the new value. -
${endpoint_name}
By default, the Java class simple name is taken. It is possible to specify a value in the@Endpoint
annotation to override default one:@Endpoint("customName")
. In this case, thecustomName
value will be used as a${endpoint_name}
to accept incoming requests, also case-insensitive.