
com.zandero.rest.writer.JsonResponseWriter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rest.vertx Show documentation
Show all versions of rest.vertx Show documentation
JAX-RS REST annotation processor for vert.x verticals
The newest version!
package com.zandero.rest.writer;
import com.zandero.utils.extra.*;
import io.vertx.core.http.*;
import io.vertx.core.json.jackson.*;
/**
* Converts result into JSON object if not null
*/
// @Produces("application/json")
public class JsonResponseWriter implements HttpResponseWriter {
// TODO: add custom mapper ... to override vertx.mapper if desired
// TODO: add logging of response for convenience as trace if anybody needs it
@Override
public void write(T result, HttpServerRequest request, HttpServerResponse response) {
if (result != null) {
response.end(JsonUtils.toJson(result, DatabindCodec.mapper()));
} else {
response.end();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy