dss icon indicating copy to clipboard operation
dss copied to clipboard

[BUG]Not expected response

Open ztkmkoo opened this issue 4 years ago • 6 comments

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 image

Desktop (please complete the following information):

  • OS: Ubuntu 16.04
  • Test: Insomnia

ztkmkoo avatar May 31 '20 15:05 ztkmkoo

The PR #42 is just a temporary solution.

ztkmkoo avatar Jun 01 '20 23:06 ztkmkoo

@Doyuni Are you in progress?

ztkmkoo avatar Aug 08 '20 18:08 ztkmkoo

@ztkmkoo Oh...it may have been committed while resolve merge conflict. Can I try this?

Doyuni avatar Aug 08 '20 22:08 Doyuni

@Doyuni Of course

ztkmkoo avatar Aug 09 '20 04:08 ztkmkoo

@ztkmkoo

The PR #42 is just a temporary solution.

Can I ask why it is a temporary solution?

Doyuni avatar Aug 13 '20 13:08 Doyuni

@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

ztkmkoo avatar Aug 13 '20 14:08 ztkmkoo