Skip to content

Commit

Permalink
chore: implement ClientRoutesProvider
Browse files Browse the repository at this point in the history
ClientRoutesProvider interface from flow-server is used by Flow to read a list of available client routes. Hilla can implement it in ClientRouteRegistry, which is already a Spring bean, and this way Flow finds it automatically.

Related-to: vaadin/flow/isues/18857
  • Loading branch information
tltv committed Apr 3, 2024
1 parent 0961d0b commit c557b84
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.util.AntPathMatcher;
import com.vaadin.flow.router.internal.ClientRoutesProvider;

import java.io.IOException;
import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Paths;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Objects;
Expand All @@ -40,7 +41,7 @@
* Keeps track of registered client side routes.
*/
@Component
public class ClientRouteRegistry implements Serializable {
public class ClientRouteRegistry implements ClientRoutesProvider {

/**
* A map of registered routes and their corresponding client view
Expand Down Expand Up @@ -184,4 +185,10 @@ private void registerAndRecurseChildren(String basePath,
});
}
}

@Override
public List<String> getClientRoutes() {
return getAllRoutes().keySet().stream().toList();
}

}

0 comments on commit c557b84

Please sign in to comment.