Skip to content
This repository has been archived by the owner on May 6, 2021. It is now read-only.

Latest commit

 

History

History
71 lines (54 loc) · 2.47 KB

typescript-endpoints-urls.asciidoc

File metadata and controls

71 lines (54 loc) · 2.47 KB
title order layout
Appendix: Endpoint URLs
160
page

Appendix: 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:

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, 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 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 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

Vaadin allows to configure the following url parts:

  • ${prefix} The default value is connect. To change it to some other value, provide application.properties file in the project resources: src/main/resources/application.properties and set the vaadin.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, the customName value will be used as a ${endpoint_name} to accept incoming requests, also case-insensitive.