Skip to content

Commit

Permalink
Merge branch 'master' into loomClient
Browse files Browse the repository at this point in the history
  • Loading branch information
SentryMan authored Oct 13, 2024
2 parents 63e3fe4 + 42e5468 commit d9ff775
Show file tree
Hide file tree
Showing 34 changed files with 127 additions and 69 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public class WidgetController$Route implements HttpFeature {
private void _getById(ServerRequest req, ServerResponse res) throws Exception {
res.status(OK_200);
var pathParams = req.path().pathParameters();
var id = asInt(pathParams.first("id").get());
var id = asInt(pathParams.contains("id") ? pathParams.get("id") : null);
var result = controller.getById(id);
res.send(result);
}
Expand Down Expand Up @@ -263,7 +263,7 @@ public class WidgetController$Route implements HttpFeature {
private void _getById(ServerRequest req, ServerResponse res) throws Exception {
res.status(OK_200);
var pathParams = req.path().pathParameters();
var id = asInt(pathParams.first("id").get());
var id = asInt(pathParams.contains("id") ? pathParams.get("id") : null);
var result = controller.getById(id);
res.headers().contentType(MediaTypes.APPLICATION_JSON);
//jsonb has a special accommodation for helidon to improve performance
Expand Down
2 changes: 1 addition & 1 deletion htmx-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-http-parent</artifactId>
<version>2.8-RC1</version>
<version>2.8-RC3</version>
</parent>

<artifactId>avaje-htmx-api</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions htmx-nima-jstache/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-http-parent</artifactId>
<version>2.8-RC1</version>
<version>2.8-RC3</version>
</parent>

<artifactId>avaje-htmx-nima-jstache</artifactId>
Expand Down Expand Up @@ -39,7 +39,7 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-inject</artifactId>
<version>10.3</version>
<version>10.4</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
Expand Down
6 changes: 3 additions & 3 deletions htmx-nima/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-http-parent</artifactId>
<version>2.8-RC1</version>
<version>2.8-RC3</version>
</parent>

<artifactId>avaje-htmx-nima</artifactId>
Expand All @@ -21,12 +21,12 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-htmx-api</artifactId>
<version>2.8-RC1</version>
<version>2.8-RC3</version>
</dependency>
<dependency>
<groupId>io.helidon.webserver</groupId>
<artifactId>helidon-webserver</artifactId>
<version>4.1.0</version>
<version>4.1.2</version>
</dependency>
</dependencies>
</project>
2 changes: 1 addition & 1 deletion http-api-javalin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-http-parent</artifactId>
<version>2.8-RC1</version>
<version>2.8-RC3</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion http-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-http-parent</artifactId>
<version>2.8-RC1</version>
<version>2.8-RC3</version>
<relativePath>..</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions http-client-gson-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-http-parent</artifactId>
<version>2.8-RC1</version>
<version>2.8-RC3</version>
</parent>

<artifactId>avaje-http-client-gson</artifactId>
Expand All @@ -20,7 +20,7 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-http-client</artifactId>
<version>2.8-RC1</version>
<version>2.8-RC3</version>
<scope>provided</scope>
</dependency>

Expand Down
4 changes: 2 additions & 2 deletions http-client-moshi-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-http-parent</artifactId>
<version>2.8-RC1</version>
<version>2.8-RC3</version>
</parent>
<artifactId>avaje-http-client-moshi</artifactId>

Expand All @@ -19,7 +19,7 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-http-client</artifactId>
<version>2.8-RC1</version>
<version>2.8-RC3</version>
<scope>provided</scope>
</dependency>

Expand Down
12 changes: 6 additions & 6 deletions http-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-http-parent</artifactId>
<version>2.8-RC1</version>
<version>2.8-RC3</version>
</parent>

<artifactId>avaje-http-client</artifactId>
Expand All @@ -29,21 +29,21 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.2</version>
<version>2.18.0</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jsonb</artifactId>
<version>2.1</version>
<version>2.2</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-inject</artifactId>
<version>10.3</version>
<version>10.4</version>
<optional>true</optional>
</dependency>

Expand All @@ -66,7 +66,7 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-http-api</artifactId>
<version>2.8-RC1</version>
<version>2.8-RC3</version>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -99,7 +99,7 @@
<path>
<groupId>io.avaje</groupId>
<artifactId>avaje-inject-generator</artifactId>
<version>10.3</version>
<version>10.4</version>
</path>
</annotationProcessorPaths>
</configuration>
Expand Down
2 changes: 1 addition & 1 deletion http-generator-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-http-parent</artifactId>
<version>2.8-RC1</version>
<version>2.8-RC3</version>
</parent>

<artifactId>avaje-http-client-generator</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion http-generator-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-http-parent</artifactId>
<version>2.8-RC1</version>
<version>2.8-RC3</version>
</parent>

<artifactId>avaje-http-generator-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ static String serialize(Object obj) throws IllegalAccessException {
for (final Field field : fields) {

// skip JsonIgnored fields
if ("BIND_TYPE_AND_TYPES".equals(field.getName())
if ("SCHEMA_RESOLUTION_PROPERTY".equals(field.getName())
|| "BIND_TYPE_AND_TYPES".equals(field.getName())
|| "BINARY_STRING_CONVERSION_PROPERTY".equals(field.getName())
|| "COMPONENTS_SCHEMAS_REF".equals(field.getName())
|| "exampleSetFlag".equals(field.getName())
Expand Down
2 changes: 1 addition & 1 deletion http-generator-helidon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<artifactId>avaje-http-parent</artifactId>
<groupId>io.avaje</groupId>
<version>2.8-RC1</version>
<version>2.8-RC3</version>
</parent>

<artifactId>avaje-http-helidon-generator</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ void writeRule() {
writer.append(" routing.addFilter(this::_%s);", method.simpleName()).eol();
} else {
writer.append(" routing.%s(\"%s\", ", webMethod.name().toLowerCase(), method.fullPath().replace("\\", "\\\\"));
var roles = method.roles();
if (!roles.isEmpty()) {
writer.append("SecurityFeature.rolesAllowed(");
writer.append("\"%s\"", Util.shortName(roles.getFirst(), true));
for (var i = 1; i < roles.size(); i++) {
writer.append(", \"%s\"", Util.shortName(roles.get(i), true));
}
writer.append("), ");
}
var hxRequest = method.hxRequest();
if (hxRequest != null) {
writer.append("HxHandler.builder(this::_%s)", method.simpleName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class ControllerWriter extends BaseControllerWriter {
reader.addImportType("io.helidon.webserver.http.ServerResponse");
reader.addImportType("io.helidon.webserver.http.HttpFeature");
reader.addImportType("io.helidon.http.HeaderNames");
if (!reader.roles().isEmpty() || reader.methods().stream().anyMatch(m -> !m.roles().isEmpty())) {
reader.addImportType("io.helidon.webserver.security.SecurityFeature");
}
if (reader.isIncludeValidator()) {
reader.addImportType("io.helidon.http.HeaderName");
}
Expand Down Expand Up @@ -202,7 +205,11 @@ private void writeClassStart() {

if (reader.isIncludeValidator()) {
writer.append(" private String language(ServerRequest req) {").eol();
writer.append(" return req.headers().first(HEADER_ACCEPT_LANGUAGE).orElse(null);").eol();
writer.append(" var headers = req.headers();").eol();
writer.append(" if (headers.contains(HEADER_ACCEPT_LANGUAGE)) {").eol();
writer.append(" return headers.get(HEADER_ACCEPT_LANGUAGE).get();").eol();
writer.append(" }").eol();
writer.append(" return null;").eol();
writer.append(" }").eol().eol();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,24 @@ public void methodRoles(List<String> roles, ControllerReader controller) {
}

private void addRoleImports(List<String> roles, ControllerReader controller) {
// nothing here yet
for (final String role : roles) {
controller.addStaticImportType(role);
}
}

@Override
public void writeReadParameter(Append writer, ParamType paramType, String paramName) {
switch (paramType) {
case PATHPARAM -> writer.append("pathParams.first(\"%s\").get()", paramName);
case PATHPARAM -> writer.append("pathParams.contains(\"%s\") ? pathParams.get(\"%s\") : null", paramName, paramName);

case QUERYPARAM -> writer.append("req.query().first(\"%s\").orElse(null)", paramName);
case QUERYPARAM -> writer.append("req.query().contains(\"%s\") ? req.query().get(\"%s\") : null", paramName, paramName);

case FORMPARAM -> writer.append("formParams.first(\"%s\").orElse(null)", paramName);
case FORMPARAM -> writer.append("formParams.contains(\"%s\") ? formParams.get(\"%s\") : null", paramName, paramName);

case HEADER -> writer.append(
"req.headers().value(HeaderNames.create(\"%s\")).orElse(null)", paramName);

case COOKIE -> writer.append("req.headers().cookies().first(\"%s\").orElse(null)", paramName);
case COOKIE -> writer.append("req.headers().cookies().contains(\"%s\") ? req.headers().cookies().get(\"%s\") : null", paramName, paramName);

default -> writer.append("null // TODO req.%s().param(\"%s\")", paramType.type(), paramName);
}
Expand All @@ -86,19 +88,19 @@ public void writeReadParameter(Append writer, ParamType paramType, String paramN
public void writeReadParameter(Append writer, ParamType paramType, String paramName, String paramDefault) {
switch (paramType) {
case PATHPARAM -> writer.append(
"pathParams.first(\"%s\").orElse(\"%s\")", paramName, paramDefault);
"pathParams.contains(\"%s\") ? pathParams.get(\"%s\") : \"%s\"", paramName, paramName, paramDefault);

case QUERYPARAM -> writer.append(
"req.query().first(\"%s\").orElse(\"%s\")", paramName, paramDefault);
"req.query().contains(\"%s\") ? req.query().get(\"%s\") : \"%s\"", paramName, paramName, paramDefault);

case FORMPARAM -> writer.append(
"formParams.first(\"%s\").orElse(\"%s\")", paramName, paramDefault);
"formParams.contains(\"%s\") ? formParams.get(\"%s\") : \"%s\"", paramName, paramName, paramDefault);

case HEADER -> writer.append(
"req.headers().value(Http.Header.create(\"%s\").orElse(\"%s\")", paramName, paramDefault);

case COOKIE -> writer.append(
"req.headers().cookies().first(\"%s\").orElse(\"%s\")", paramName, paramDefault);
"req.headers().cookies().contains(\"%s\") ? req.headers().cookies().get(\"%s\") : \"%s\"", paramName, paramName, paramDefault);

default -> writer.append("null // TODO req.%s().param(\"%s\")", paramType.type(), paramName);
}
Expand Down
2 changes: 1 addition & 1 deletion http-generator-javalin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-http-parent</artifactId>
<version>2.8-RC1</version>
<version>2.8-RC3</version>
</parent>

<artifactId>avaje-http-javalin-generator</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion http-generator-jex/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-http-parent</artifactId>
<version>2.8-RC1</version>
<version>2.8-RC3</version>
</parent>

<artifactId>avaje-http-jex-generator</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion http-generator-sigma/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-http-parent</artifactId>
<version>2.8-RC1</version>
<version>2.8-RC3</version>
</parent>

<artifactId>avaje-http-sigma-generator</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions http-inject-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>io.avaje</groupId>
<artifactId>avaje-http-parent</artifactId>
<version>2.8-RC1</version>
<version>2.8-RC3</version>
<relativePath>..</relativePath>
</parent>

Expand All @@ -19,7 +19,7 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-inject</artifactId>
<version>10.3</version>
<version>10.4</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<parent>
<groupId>org.avaje</groupId>
<artifactId>java11-oss</artifactId>
<version>4.4</version>
<version>4.5</version>
</parent>

<groupId>io.avaje</groupId>
<artifactId>avaje-http-parent</artifactId>
<version>2.8-RC1</version>
<version>2.8-RC3</version>
<packaging>pom</packaging>

<scm>
Expand All @@ -19,9 +19,9 @@

<properties>
<nexus.staging.autoReleaseAfterClose>true</nexus.staging.autoReleaseAfterClose>
<swagger.version>2.2.23</swagger.version>
<swagger.version>2.2.25</swagger.version>
<jackson.version>2.14.2</jackson.version>
<avaje.prisms.version>1.31</avaje.prisms.version>
<avaje.prisms.version>1.32</avaje.prisms.version>
<module-info.shade>${project.build.directory}${file.separator}module-info.shade</module-info.shade>
</properties>

Expand Down
Loading

0 comments on commit d9ff775

Please sign in to comment.