|
1 | 1 | package io.avaje.http.generator.client; |
2 | 2 |
|
3 | | -import io.avaje.http.generator.core.*; |
4 | | -import io.avaje.http.generator.core.PathSegments.Segment; |
| 3 | +import static io.avaje.http.generator.core.ProcessingContext.isAssignable2Interface; |
| 4 | +import static io.avaje.http.generator.core.ProcessingContext.logError; |
| 5 | +import static io.avaje.http.generator.core.ProcessingContext.typeElement; |
| 6 | +import static java.util.stream.Collectors.toList; |
| 7 | +import static java.util.stream.Collectors.toMap; |
5 | 8 |
|
6 | | -import javax.lang.model.element.TypeElement; |
7 | | -import javax.lang.model.util.ElementFilter; |
8 | 9 | import java.util.List; |
9 | 10 | import java.util.Map; |
10 | 11 | import java.util.Map.Entry; |
|
13 | 14 | import java.util.stream.Collectors; |
14 | 15 | import java.util.stream.Stream; |
15 | 16 |
|
16 | | -import static io.avaje.http.generator.core.ProcessingContext.*; |
17 | | -import static java.util.stream.Collectors.toList; |
18 | | -import static java.util.stream.Collectors.toMap; |
| 17 | +import javax.lang.model.element.TypeElement; |
| 18 | +import javax.lang.model.util.ElementFilter; |
| 19 | + |
| 20 | +import io.avaje.http.generator.core.APContext; |
| 21 | +import io.avaje.http.generator.core.Append; |
| 22 | +import io.avaje.http.generator.core.BeanParamReader; |
| 23 | +import io.avaje.http.generator.core.ControllerReader; |
| 24 | +import io.avaje.http.generator.core.MethodParam; |
| 25 | +import io.avaje.http.generator.core.MethodReader; |
| 26 | +import io.avaje.http.generator.core.ParamType; |
| 27 | +import io.avaje.http.generator.core.PathSegments; |
| 28 | +import io.avaje.http.generator.core.PathSegments.Segment; |
| 29 | +import io.avaje.http.generator.core.ProcessingContext; |
| 30 | +import io.avaje.http.generator.core.RequestTimeoutPrism; |
| 31 | +import io.avaje.http.generator.core.UType; |
| 32 | +import io.avaje.http.generator.core.Util; |
| 33 | +import io.avaje.http.generator.core.WebMethod; |
19 | 34 |
|
20 | 35 | /** |
21 | 36 | * Write code to register Web route for a given controller method. |
@@ -399,16 +414,36 @@ private void writePaths(Set<PathSegments.Segment> segments) { |
399 | 414 | if (!segments.isEmpty()) { |
400 | 415 | writer.append(" "); |
401 | 416 | } |
402 | | - for (PathSegments.Segment segment : segments) { |
| 417 | + |
| 418 | + StringBuilder combinedLiterals = new StringBuilder(); |
| 419 | + |
| 420 | + for (var segment : segments) { |
403 | 421 | if (segment.isLiteral()) { |
404 | | - writer.append(".path(\"").append(segment.literalSection()).append("\")"); |
405 | | - } else if (segment.isProperty()) { |
406 | | - writer.append(".path(").append(segmentPropertyMap.get(segment.name())).append(")"); |
| 422 | + // Accumulate literal segments with "/" delimiter |
| 423 | + if (combinedLiterals.length() > 0) { |
| 424 | + combinedLiterals.append("/"); |
| 425 | + } |
| 426 | + combinedLiterals.append(segment.literalSection()); |
407 | 427 | } else { |
408 | | - writer.append(".path(").append(segment.name()).append(")"); |
409 | | - // TODO: matrix params |
| 428 | + // If we have accumulated literals, write them out first |
| 429 | + if (combinedLiterals.length() > 0) { |
| 430 | + writer.append(".path(\"").append(combinedLiterals.toString()).append("\")"); |
| 431 | + combinedLiterals.setLength(0); // Clear the buffer |
| 432 | + } |
| 433 | + // Write the non-literal segment |
| 434 | + if (segment.isProperty()) { |
| 435 | + writer.append(".path(").append(segmentPropertyMap.get(segment.name())).append(")"); |
| 436 | + } else { |
| 437 | + writer.append(".path(").append(segment.name()).append(")"); |
| 438 | + } |
410 | 439 | } |
411 | 440 | } |
| 441 | + |
| 442 | + // Write any remaining accumulated literals |
| 443 | + if (combinedLiterals.length() > 0) { |
| 444 | + writer.append(".path(\"").append(combinedLiterals.toString()).append("\")"); |
| 445 | + } |
| 446 | + |
412 | 447 | if (!segments.isEmpty()) { |
413 | 448 | writer.eol(); |
414 | 449 | } |
|
0 commit comments