Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerald Unterrainer committed Oct 20, 2021
2 parents 468cb8e + ff7c524 commit e9a8fc5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<modelVersion>4.0.0</modelVersion>
<artifactId>http-server</artifactId>
<version>0.2.35</version>
<version>0.2.36</version>
<name>HttpServer</name>
<packaging>jar</packaging>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,25 @@ else if (mandatory)
return result;
}

public Double getQueryParamAsDouble(final Context ctx, final String name) {
return getQueryParamAsDouble(ctx, name, true, null);
}

public Double getQueryParamAsDouble(final Context ctx, final String name, final Double defaultValue) {
return getQueryParamAsDouble(ctx, name, false, defaultValue);
}

private Double getQueryParamAsDouble(final Context ctx, final String name, final boolean mandatory,
final Double defaultValue) {
String o = ctx.queryParam(name);
Double result = defaultValue;
if (o != null)
result = convertToDouble(o);
else if (mandatory)
throw new BadRequestException(String.format("Parameter %s is mandatory", name));
return result;
}

public long convertToLong(final String s) {
try {
return Long.parseLong(s);
Expand Down

0 comments on commit e9a8fc5

Please sign in to comment.