dss
dss copied to clipboard
[BUG]Not expected response
Describe the bug The http rest response is not expected value. for dss-0.0.2.
my test code:
public class Application {
public static void main(String[] args) throws InterruptedException {
DssRestServer dssRestServer = new DssRestServer("127.0.0.1", 8181);
dssRestServer
.addDssRestService(new MyService())
.addDssRestService(new YourService());
dssRestServer.start();
}
}
public class MyService implements DssRestActorService {
public String getName() {
return "myService";
}
public String getPath() {
return "/my/service";
}
public DssRestMethodType getMethodType() {
return DssRestMethodType.GET;
}
public DssRestContentInfo getConsume() {
return DssRestContentInfo.APPLICATION_JSON_UTF8;
}
public DssRestContentInfo getProduce() {
return DssRestContentInfo.APPLICATION_JSON_UTF8;
}
public DssRestServiceResponse handling(DssRestServiceActorCommandRequest commandRequest) {
final String myName = commandRequest.getContent();
final MyServiceResponse response = new MyServiceResponse();
response.setResult("My service is " + myName + " service");
return response;
}
}
Expected behavior Expected response like
{
"result" : "My service is Kebron service"
}
Screenshots
Desktop (please complete the following information):
- OS: Ubuntu 16.04
- Test: Insomnia
The PR #42 is just a temporary solution.
@Doyuni Are you in progress?
@ztkmkoo Oh...it may have been committed while resolve merge conflict. Can I try this?
@Doyuni Of course
@ztkmkoo
The PR #42 is just a temporary solution.
Can I ask why it is a temporary solution?
@Doyuni Hi,
Please see io.github.ztkmkoo.dss.core.network.rest.handler.DssRestHandler$responseFromServiceActor
, it always converts the DssRestServiceResponse object to json string.
But, see io.github.ztkmkoo.dss.core.actor.rest.service.AbstractDssRestActorService
, it has the DssRestContentInfo produce
member.
We have to support not only json format. So we should let io.github.ztkmkoo.dss.core.actor.rest.DssRestServiceActor
make the correct(?) response.
Maybe we need modify io.github.ztkmkoo.dss.core.message.rest.DssRestChannelHandlerCommandResponse
class, and send response logic in io.github.ztkmkoo.dss.core.network.rest.handler.DssRestHandler