|
8 | 8 | import static io.jooby.internal.pac4j.ClientReference.lazyClientNameList; |
9 | 9 | import static java.util.Optional.ofNullable; |
10 | 10 |
|
11 | | -import java.util.ArrayList; |
12 | | -import java.util.LinkedHashMap; |
13 | | -import java.util.List; |
14 | | -import java.util.Map; |
15 | | -import java.util.Set; |
| 11 | +import java.util.*; |
16 | 12 | import java.util.function.Function; |
17 | 13 | import java.util.stream.Collectors; |
18 | 14 | import java.util.stream.Stream; |
|
40 | 36 | import io.jooby.Context; |
41 | 37 | import io.jooby.Extension; |
42 | 38 | import io.jooby.Jooby; |
43 | | -import io.jooby.Route; |
44 | 39 | import io.jooby.Router; |
45 | 40 | import io.jooby.StatusCode; |
46 | 41 | import io.jooby.internal.pac4j.*; |
@@ -348,6 +343,8 @@ public Pac4jModule client( |
348 | 343 | public void install(@NonNull Jooby app) throws Exception { |
349 | 344 | var services = app.getServices(); |
350 | 345 | services.putIfAbsent(Pac4jOptions.class, options); |
| 346 | + app.getServices().put(Config.class, options); |
| 347 | + |
351 | 348 | // Set defaults: |
352 | 349 | services.putIfAbsent(Serializer.class, options.getSerializer()); |
353 | 350 |
|
@@ -551,23 +548,7 @@ public void install(@NonNull Jooby app) throws Exception { |
551 | 548 | app.errorCode(ForbiddenAction.class, StatusCode.FORBIDDEN); |
552 | 549 |
|
553 | 550 | /* Compute default url as next available route. We only select static path patterns. */ |
554 | | - if (options.getDefaultUrl() == null) { |
555 | | - int index = app.getRoutes().size(); |
556 | | - app.onStarting( |
557 | | - () -> { |
558 | | - List<Route> routes = app.getRoutes(); |
559 | | - String defaultUrl = app.getContextPath(); |
560 | | - if (index < routes.size()) { |
561 | | - Route route = routes.get(index); |
562 | | - if (route.getPathKeys().isEmpty()) { |
563 | | - defaultUrl = contextPath + route.getPattern(); |
564 | | - } |
565 | | - } |
566 | | - options.setDefaultUrl(defaultUrl); |
567 | | - }); |
568 | | - } |
569 | | - |
570 | | - app.getServices().put(Config.class, options); |
| 551 | + options.setDefaultUrl(Optional.ofNullable(options.getDefaultUrl()).orElse("/")); |
571 | 552 |
|
572 | 553 | /* Set current user provider */ |
573 | 554 | app.setCurrentUser(new Pac4jCurrentUser(options)); |
|
0 commit comments