Olá Jedis do GUJ, tudo bom?
Estou utilizando o protobuf para trafegar dados entre uma app mobile e o um site.
Preciso que a minha action, retorne o resultado do build do protobuf.
Gostaria de uma sugestão de qual seria a melhor estratégia para esse cenário?
Crio algum result diferente, que determine o response.contentType("application/x-protobuf")?public class MobileController {
@Get
public final AuthenticationProto.Authentication authenticate(final String login, final String password) throws IOException {
final AuthenticationToken authentication = this.service.authenticate(login, password);
final AuthenticationProto.Authentication proto = AuthenticationProto.Authentication.newBuilder()
.setStatus(AuthenticationProto.Authentication.Status.SUCCESS)
.setToken(authentication.getToken())
.build();
this.getResponse().setContentType("application/x-protobuf");
this.getResult().nothing();
return proto;
}
}
public class MobileController {
@Get
public final void authenticate(final String login, final String password) throws IOException {
final AuthenticationToken authentication = this.service.authenticate(login, password);
final AuthenticationProto.Authentication proto = AuthenticationProto.Authentication.newBuilder()
.setStatus(AuthenticationProto.Authentication.Status.SUCCESS)
.setToken(authentication.getToken())
.build();
this.getResponse().setContentType("application/x-protobuf");
proto.writeTo(this.getResponse().getOutputStream());
this.getResult().nothing();
}
}
Valeu turma, um abração.