Skip to content

Commit 38ef50f

Browse files
committed
2 parents 47d2019 + a2344c8 commit 38ef50f

File tree

4 files changed

+34
-26
lines changed

4 files changed

+34
-26
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>com.microsoft.azure.functions</groupId>
44
<artifactId>azure-functions-java-worker</artifactId>
5-
<version>1.1.0-beta7</version>
5+
<version>1.1.0-beta8</version>
66
<packaging>jar</packaging>
77

88
<name>Microsoft Azure Functions Java Runtime</name>
@@ -44,7 +44,7 @@
4444
<dependency>
4545
<groupId>com.microsoft.azure.functions</groupId>
4646
<artifactId>azure-functions-java-library</artifactId>
47-
<version>1.0.0-beta-4</version>
47+
<version>1.0.0-beta-5</version>
4848
</dependency>
4949
<dependency>
5050
<groupId>com.google.protobuf</groupId>

src/main/java/com/microsoft/azure/functions/worker/binding/RpcComplexDataSources.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import static com.microsoft.azure.functions.worker.binding.BindingData.MatchingLevel.*;
1919

20-
2120
final class ExecutionContextDataSource extends DataSource<ExecutionContext> implements ExecutionContext {
2221
ExecutionContextDataSource(String invocationId, String funcname) {
2322
super(null, null, EXECONTEXT_DATA_OPERATIONS);
@@ -112,7 +111,7 @@ private HttpRequestMessageImpl(RpcHttpRequestDataSource parentDataSource, Object
112111
@Override
113112
public URI getUri() { return URI.create(this.parentDataSource.httpPayload.getUrl()); }
114113
@Override
115-
public String getMethod() { return this.parentDataSource.httpPayload.getMethod(); }
114+
public HttpMethod getHttpMethod() { return HttpMethod.value(this.parentDataSource.httpPayload.getMethod()); }
116115
@Override
117116
public Map<String, String> getHeaders() { return this.parentDataSource.httpPayload.getHeadersMap(); }
118117
@Override
@@ -121,16 +120,8 @@ private HttpRequestMessageImpl(RpcHttpRequestDataSource parentDataSource, Object
121120
public Object getBody() { return this.body; }
122121

123122
@Override
124-
public HttpResponseMessage createResponse(int status) {
125-
return createResponse(status, null);
126-
}
127-
128-
@Override
129-
public HttpResponseMessage createResponse(int status, Object body) {
130-
RpcHttpDataTarget response = new RpcHttpDataTarget();
131-
response.setStatus(status);
132-
response.setBody(body);
133-
return response;
123+
public HttpResponseMessage.Builder createResponseBuilder(HttpStatus status) {
124+
return new RpcHttpDataTarget().status(status);
134125
}
135126

136127
private RpcHttpRequestDataSource parentDataSource;

src/main/java/com/microsoft/azure/functions/worker/binding/RpcDataTargets.java

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,29 @@
1111

1212
import static com.microsoft.azure.functions.worker.binding.BindingData.MatchingLevel.*;
1313

14-
final class RpcHttpDataTarget extends DataTarget implements HttpResponseMessage {
14+
final class RpcHttpDataTarget extends DataTarget implements HttpResponseMessage, HttpResponseMessage.Builder {
1515
RpcHttpDataTarget() {
1616
super(HTTP_TARGET_OPERATIONS);
1717
this.headers = new HashMap<>();
18-
this.status = 200;
18+
this.status = HttpStatus.valueOf(200);
1919
super.setValue(this);
2020
}
2121

2222
@Override
23-
public int getStatus() { return this.status; }
24-
@Override
25-
public void setStatus(int status) { this.status = status; }
26-
@Override
27-
public void addHeader(String key, String value) { this.headers.put(key, value); }
23+
public HttpStatus getStatus() { return this.status; }
2824
@Override
2925
public String getHeader(String key) { return this.headers.get(key); }
3026
@Override
3127
public Object getBody() { return this.body; }
32-
@Override
33-
public void setBody(Object body) { this.body = body; }
3428

35-
private int status;
29+
private HttpStatus status;
3630
private Object body;
3731
private Map<String, String> headers;
3832

3933
private static TypedData.Builder toHttpData(RpcHttpDataTarget response) {
4034
TypedData.Builder dataBuilder = TypedData.newBuilder();
4135
if (response != null) {
42-
RpcHttp.Builder httpBuilder = RpcHttp.newBuilder().setStatusCode(response.getStatus() + "");
36+
RpcHttp.Builder httpBuilder = RpcHttp.newBuilder().setStatusCode(response.getStatus().value() + "");
4337
response.headers.forEach(httpBuilder::putHeaders);
4438
RpcUnspecifiedDataTarget bodyTarget = new RpcUnspecifiedDataTarget();
4539
bodyTarget.setValue(response.getBody());
@@ -54,6 +48,29 @@ private static TypedData.Builder toHttpData(RpcHttpDataTarget response) {
5448
HTTP_TARGET_OPERATIONS.addOperation(TYPE_ASSIGNMENT, HttpResponseMessage.class, v -> toHttpData((RpcHttpDataTarget) v));
5549
HTTP_TARGET_OPERATIONS.addOperation(TYPE_ASSIGNMENT, RpcHttpDataTarget.class, v -> toHttpData((RpcHttpDataTarget) v));
5650
}
51+
52+
@Override
53+
public Builder status(HttpStatus status) {
54+
this.status = status;
55+
return this;
56+
}
57+
58+
@Override
59+
public Builder header(String key, String value) {
60+
this.headers.put(key, value);
61+
return this;
62+
}
63+
64+
@Override
65+
public Builder body(Object body) {
66+
this.body = body;
67+
return this;
68+
}
69+
70+
@Override
71+
public HttpResponseMessage build() {
72+
return this;
73+
}
5774
}
5875

5976
final class RpcUnspecifiedDataTarget extends DataTarget {

tools/AzureFunctionsJavaWorker.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<id>Microsoft.Azure.Functions.JavaWorker</id>
55
<title>Microsoft Azure Functions Java Worker</title>
66
<tags>java azure-functions azure</tags>
7-
<version>1.1.0-beta7$version$</version>
7+
<version>1.1.0-beta8$version$</version>
88
<authors>Microsoft</authors>
99
<owners>Microsoft</owners>
1010
<projectUrl>https://github.com/Azure/azure-functions-java-worker</projectUrl>

0 commit comments

Comments
 (0)