Skip to content

Commit

Permalink
Merge pull request #13 from reeyur/bugfix/update-request-response
Browse files Browse the repository at this point in the history
Request和Response声明数据时,去掉显式new HashMap,否在客户在用的时候,被限制为HashMap类型数据,改为灵活一…
  • Loading branch information
yury-awesome authored Oct 16, 2019
2 parents 6d19962 + 3d729c2 commit bc62b01
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
18 changes: 9 additions & 9 deletions src/main/java/com/meituan/lyrebird/client/api/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@

@JsonIgnoreProperties(ignoreUnknown = true)
public class Request {
private Map<String, String> headers = new HashMap<>();
private Map headers;
private String method;
private Map<String, String> query = new HashMap<>();
private Map query;
private String url;
private String host;
private String path;
private Map<String, ?> data = new HashMap<>();
private Map data;

public Map<String, String> getHeaders() {
public Map getHeaders() {
return headers;
}

public void setHeaders(Map<String, String> headers) {
public void setHeaders(Map headers) {
this.headers = headers;
}

Expand All @@ -31,11 +31,11 @@ public void setMethod(String method) {
this.method = method;
}

public Map<String, String> getQuery() {
public Map getQuery() {
return query;
}

public void setQuery(Map<String, String> query) {
public void setQuery(Map query) {
this.query = query;
}

Expand Down Expand Up @@ -63,11 +63,11 @@ public void setPath(String path) {
this.path = path;
}

public Map<String, ?> getData() {
public Map getData() {
return data;
}

public void setData(Map<String, ?> data) {
public void setData(Map data) {
this.data = data;
}
}
13 changes: 6 additions & 7 deletions src/main/java/com/meituan/lyrebird/client/api/Response.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.meituan.lyrebird.client.api;

import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
Expand All @@ -9,8 +8,8 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public class Response {
private int code;
private Map<String, String> headers = new HashMap<>();
private Map<String, ?> data = new HashMap<>();
private Map headers;
private Map data;

public int getCode() {
return code;
Expand All @@ -20,11 +19,11 @@ public void setCode(int code) {
this.code = code;
}

public Map<String, String> getHeaders() {
public Map getHeaders() {
return headers;
}

public void setHeaders(Map<String, String> headers) {
public void setHeaders(Map headers) {
this.headers = headers;
}

Expand All @@ -33,7 +32,7 @@ public void setHeaders(Map<String, String> headers) {
*
* @return 服务端返回数据映射的 Java 对象
*/
public Map<String, ?> getData() {
public Map getData() {
return data;
}

Expand All @@ -60,7 +59,7 @@ public <T> T getData(String jsonPath, Class<T> type) {
return JsonPath.parse(data).read(jsonPath, type);
}

public void setData(Map<String, ?> data) {
public void setData(Map data) {
this.data = data;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void testFlowRequest() throws LyrebirdClientException {
FlowDetail flow = this.lyrebird.getFlowDetail("67ea0002-9566-41db-8178-ca0c2f82a71a");

assertEquals("tester", flow.getRequest().getQuery().get("name"));
assertEquals(null, flow.getRequest().getData().get("age"));
assertEquals(null, flow.getRequest().getData());
assertEquals("http://www.lyrebird.java.client.com/api/example", flow.getRequest().getUrl());
}

Expand Down

0 comments on commit bc62b01

Please sign in to comment.